1.運維作業記錄 part1
This commit is contained in:
parent
6174a0d452
commit
566d52dd7c
@ -14,10 +14,16 @@ namespace SolarPower.Controllers
|
|||||||
public class OperationController : MyBaseController<OperationController>
|
public class OperationController : MyBaseController<OperationController>
|
||||||
{
|
{
|
||||||
private readonly IOperationRepository operationRepository;
|
private readonly IOperationRepository operationRepository;
|
||||||
|
private string operationRecodeFilePath = "/upload/operation_recode/";
|
||||||
|
private string operationRecodeSaveAsPath = "";
|
||||||
|
|
||||||
|
|
||||||
public OperationController(
|
public OperationController(
|
||||||
IOperationRepository operationRepository) : base()
|
IOperationRepository operationRepository) : base()
|
||||||
{
|
{
|
||||||
this.operationRepository = operationRepository;
|
this.operationRepository = operationRepository;
|
||||||
|
|
||||||
|
operationRecodeSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_recode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -35,13 +41,13 @@ namespace SolarPower.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="post"></param>
|
/// <param name="post"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ActionResult> GetPowerStationSelectOption(int post)
|
public async Task<ApiResult<List<PowerStationIdList>>> GetPowerStationSelectOption()
|
||||||
{
|
{
|
||||||
ApiResult<List<PowerStationIdList>> apiResult = new ApiResult<List<PowerStationIdList>>();
|
ApiResult<List<PowerStationIdList>> apiResult = new ApiResult<List<PowerStationIdList>>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var PowerStationIdLists = new List<PowerStationIdList>();
|
var PowerStationIdLists = new List<PowerStationIdList>();
|
||||||
PowerStationIdLists = await operationRepository.GetPowerStationIdList(myUser.Id) ;
|
PowerStationIdLists = await operationRepository.GetPowerStationIdList(myUser.Id);
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = PowerStationIdLists;
|
apiResult.Data = PowerStationIdLists;
|
||||||
}
|
}
|
||||||
@ -52,13 +58,7 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
var result = Json(new
|
|
||||||
{
|
|
||||||
data = apiResult
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -189,7 +189,7 @@ namespace SolarPower.Controllers
|
|||||||
OperationPlanTable = await operationRepository.OperationPlanTable(id);
|
OperationPlanTable = await operationRepository.OperationPlanTable(id);
|
||||||
foreach (OperationPlanTable a in OperationPlanTable)
|
foreach (OperationPlanTable a in OperationPlanTable)
|
||||||
{
|
{
|
||||||
if(a.Type == 0)
|
if (a.Type == 0)
|
||||||
{
|
{
|
||||||
a.TypeName = "清洗";
|
a.TypeName = "清洗";
|
||||||
}
|
}
|
||||||
@ -198,9 +198,9 @@ namespace SolarPower.Controllers
|
|||||||
a.TypeName = "巡檢";
|
a.TypeName = "巡檢";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(a.ScheduleType == 0)
|
if (a.ScheduleType == 0)
|
||||||
{
|
{
|
||||||
a.Schedule = "每" + a.ScheduleNum.ToString() + "天" ;
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "天";
|
||||||
}
|
}
|
||||||
else if (a.ScheduleType == 1)
|
else if (a.ScheduleType == 1)
|
||||||
{
|
{
|
||||||
@ -223,11 +223,11 @@ namespace SolarPower.Controllers
|
|||||||
var crst = a.CreatedAt.Split(" ");
|
var crst = a.CreatedAt.Split(" ");
|
||||||
a.CreateTimeString = crst[0];
|
a.CreateTimeString = crst[0];
|
||||||
|
|
||||||
if(a.EmailType == 0)
|
if (a.EmailType == 0)
|
||||||
{
|
{
|
||||||
a.EmailTypeName = "當天";
|
a.EmailTypeName = "當天";
|
||||||
}
|
}
|
||||||
else if(a.EmailType == 1)
|
else if (a.EmailType == 1)
|
||||||
{
|
{
|
||||||
a.EmailTypeName = "前一天";
|
a.EmailTypeName = "前一天";
|
||||||
}
|
}
|
||||||
@ -341,6 +341,20 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
||||||
|
|
||||||
|
foreach (var recode in recodes)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(recode.FormId))
|
||||||
|
{
|
||||||
|
recode.FormId = @$"<a href='javascript:;' class='btn btn-success waves-effect waves-themed mb-3 mr-2 edit-btn'>填寫表單</a>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
recode.FormId = @$"<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>{recode.FormId}</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO 替換圖片檔案
|
||||||
|
}
|
||||||
|
|
||||||
totalRecords = recodes.Count();
|
totalRecords = recodes.Count();
|
||||||
recFilter = recodes.Count();
|
recFilter = recodes.Count();
|
||||||
|
|
||||||
@ -365,5 +379,293 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取得單一運維作業記錄列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="post"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<OperationRecode>> GetOneOperationRecode(int id)
|
||||||
|
{
|
||||||
|
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();
|
||||||
|
|
||||||
|
OperationRecode operationRecode;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
//if (!IsPlatformLayer(myUser.Role.Layer))
|
||||||
|
//{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
|
||||||
|
// post.SelectedCompanyId = myUser.CompanyId;
|
||||||
|
//}
|
||||||
|
|
||||||
|
operationRecode = await operationRepository.GetOneOperationRecodeAsync(id);
|
||||||
|
|
||||||
|
if (operationRecode == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9989";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var recodeFile in operationRecode.RecodeFiles)
|
||||||
|
{
|
||||||
|
recodeFile.FileName = Path.Combine(operationRecodeFilePath, operationRecode.Id.ToString()) + "/" + recodeFile.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = operationRecode;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<OperationRecode>> SaveOperationRecode([FromForm] PostOperationRecode post)
|
||||||
|
{
|
||||||
|
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();
|
||||||
|
|
||||||
|
OperationRecode operationRecode = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id);
|
||||||
|
|
||||||
|
//取得運維作業記錄最後流水號
|
||||||
|
var currentSerialNumber = await operationRepository.GetCurrentSerialNumber("operation_record");
|
||||||
|
|
||||||
|
if (operationRecode == null)
|
||||||
|
{
|
||||||
|
if (post.Id != 0)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9989";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 新增運維作業記錄 - 維修單
|
||||||
|
|
||||||
|
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||||
|
|
||||||
|
var finishTime = string.Empty;
|
||||||
|
if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
||||||
|
{
|
||||||
|
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
operationRecode = new OperationRecode()
|
||||||
|
{
|
||||||
|
FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber,
|
||||||
|
SerialNumber = tempSerialNumber,
|
||||||
|
PowerStationId = post.PowerStationId,
|
||||||
|
WorkType = post.WorkType,
|
||||||
|
ErrorCode = post.ErrorCode,
|
||||||
|
FixDo = post.FixDo,
|
||||||
|
Status = post.Status,
|
||||||
|
WorkPersonId = post.WorkPersonId,
|
||||||
|
FinishTime = finishTime,
|
||||||
|
WorkTime = post.WorkTime,
|
||||||
|
Notice = post.Notice,
|
||||||
|
Description = post.Description,
|
||||||
|
CreatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"FormId",
|
||||||
|
"SerialNumber",
|
||||||
|
"PowerStationId",
|
||||||
|
"WorkType",
|
||||||
|
"ErrorCode",
|
||||||
|
"FixDo",
|
||||||
|
"Status",
|
||||||
|
"WorkPersonId",
|
||||||
|
"FinishTime",
|
||||||
|
"WorkTime",
|
||||||
|
"Notice",
|
||||||
|
"Description",
|
||||||
|
"CreatedBy"
|
||||||
|
};
|
||||||
|
|
||||||
|
var id = await operationRepository.AddOneOperationRecodeAsync(operationRecode, properties);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Msg = "儲存成功";
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 修改運維作業記錄
|
||||||
|
|
||||||
|
var finishTime = string.Empty;
|
||||||
|
if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
||||||
|
{
|
||||||
|
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operationRecode.WorkType != (int)OperationRecodeWorkTypeEnum.Fix)
|
||||||
|
{ //針對清洗、巡檢
|
||||||
|
var now = DateTime.Now;
|
||||||
|
|
||||||
|
var startTime = DateTime.Parse(post.StartTime + " 00:00:00");
|
||||||
|
var endTime = DateTime.Parse(post.EndTime + " 23:59:59");
|
||||||
|
|
||||||
|
if (now > endTime)
|
||||||
|
{
|
||||||
|
if (post.Status == (int)OperationRecodeStatusEnum.NoneComplete)
|
||||||
|
{ //超過時間修改成 未完成-過期
|
||||||
|
post.Status = (int)OperationRecodeStatusEnum.NoneCompleteExpired;
|
||||||
|
}
|
||||||
|
else if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
||||||
|
{ //超過時間修改成 完成-過期
|
||||||
|
post.Status = (int)OperationRecodeStatusEnum.CompleteExpired;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateOperationRecode update = new UpdateOperationRecode()
|
||||||
|
{
|
||||||
|
Id = post.Id,
|
||||||
|
ErrorCode = post.ErrorCode,
|
||||||
|
FixDo = post.FixDo,
|
||||||
|
Status = post.Status,
|
||||||
|
FinishTime = !string.IsNullOrEmpty(finishTime) ? finishTime : null,
|
||||||
|
WorkTime = post.WorkTime,
|
||||||
|
Notice = post.Notice,
|
||||||
|
Description = post.Description,
|
||||||
|
UpdatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"Id",
|
||||||
|
"ErrorCode",
|
||||||
|
"FixDo",
|
||||||
|
"Status",
|
||||||
|
"FinishTime",
|
||||||
|
"WorkTime",
|
||||||
|
"Notice",
|
||||||
|
"Description",
|
||||||
|
"UpdatedBy",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(operationRecode.FormId))
|
||||||
|
{
|
||||||
|
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||||
|
|
||||||
|
update.FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber;
|
||||||
|
update.SerialNumber = tempSerialNumber;
|
||||||
|
|
||||||
|
properties.Add("FormId");
|
||||||
|
properties.Add("SerialNumber");
|
||||||
|
}
|
||||||
|
|
||||||
|
await operationRepository.UpdateOperationRecodeAsync(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<OperationRecode>> SaveOperationRecodeFile([FromForm] PostOperationRecode post)
|
||||||
|
{
|
||||||
|
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();
|
||||||
|
|
||||||
|
OperationRecode operationRecode = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id);
|
||||||
|
|
||||||
|
if (operationRecode == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9989";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 新增運維作業記錄檔案
|
||||||
|
List<OperationRecodeFile> operationRecodeFiles;
|
||||||
|
|
||||||
|
if (post.RecodeFiles != null && post.RecodeFiles.Length > 0)
|
||||||
|
{
|
||||||
|
FolderFunction folderFunction = new FolderFunction();
|
||||||
|
|
||||||
|
var fileSaveAsPath = Path.Combine(operationRecodeSaveAsPath, operationRecode.Id.ToString());
|
||||||
|
|
||||||
|
folderFunction.CreateFolder(fileSaveAsPath, 0);
|
||||||
|
|
||||||
|
operationRecodeFiles = new List<OperationRecodeFile>();
|
||||||
|
|
||||||
|
foreach (var file in post.RecodeFiles)
|
||||||
|
{
|
||||||
|
var split = file.FileName.Split(".");
|
||||||
|
|
||||||
|
var fileName = Guid.NewGuid() + "." + split[split.Length - 1];
|
||||||
|
|
||||||
|
var fullPath = Path.Combine(fileSaveAsPath, fileName);
|
||||||
|
|
||||||
|
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||||
|
{
|
||||||
|
file.CopyTo(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
OperationRecodeFile operationRecodeFile = new OperationRecodeFile()
|
||||||
|
{
|
||||||
|
RecordId = operationRecode.Id,
|
||||||
|
FileName = fileName,
|
||||||
|
CreatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
operationRecodeFiles.Add(operationRecodeFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> fileProperties = new List<string>()
|
||||||
|
{
|
||||||
|
"RecordId",
|
||||||
|
"FileName",
|
||||||
|
"CreatedBy"
|
||||||
|
};
|
||||||
|
|
||||||
|
await operationRepository.AddOperationRecodeFilesAsync(operationRecodeFiles, fileProperties);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,6 +143,27 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<List<OperationPersonnelSelectItemList>>> GetOperationPersonnelSelectOptionList(int powerStationId)
|
||||||
|
{
|
||||||
|
ApiResult<List<OperationPersonnelSelectItemList>> apiResult = new ApiResult<List<OperationPersonnelSelectItemList>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var personnelSelectItemLists = await powerStationRepository.GetOperationPersonnelSelectOptionListAsync(powerStationId);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = personnelSelectItemLists;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 取得單一電站基本資料
|
/// 取得單一電站基本資料
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace SolarPower.Models
|
|||||||
{
|
{
|
||||||
{ "0000", "OK" },
|
{ "0000", "OK" },
|
||||||
{ "0001", "傳入參數錯誤。" },
|
{ "0001", "傳入參數錯誤。" },
|
||||||
|
{ "9989", "查無該運維作業記錄"},
|
||||||
{ "9990", "查無該圖片"},
|
{ "9990", "查無該圖片"},
|
||||||
{ "9991", "查無該土地房屋資訊"},
|
{ "9991", "查無該土地房屋資訊"},
|
||||||
{ "9992", "查無該電站資訊"},
|
{ "9992", "查無該電站資訊"},
|
||||||
|
|||||||
@ -1,11 +1,27 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SolarPower.Models
|
namespace SolarPower.Models
|
||||||
{
|
{
|
||||||
public class Operation:Created
|
public enum OperationRecodeStatusEnum : byte
|
||||||
|
{
|
||||||
|
NoneComplete = 0, //未完成
|
||||||
|
Complete = 1, //完成
|
||||||
|
NoneCompleteExpired = 2, //未完成-過期
|
||||||
|
CompleteExpired = 3, //完成-過期
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OperationRecodeWorkTypeEnum : byte
|
||||||
|
{
|
||||||
|
Clearn = 0, //清潔
|
||||||
|
Inspection = 1, //巡檢
|
||||||
|
Fix = 2, //維修
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Operation : Created
|
||||||
{
|
{
|
||||||
public int Id { get; set; }//流水號
|
public int Id { get; set; }//流水號
|
||||||
public byte Delete { get; set; }//刪除
|
public byte Delete { get; set; }//刪除
|
||||||
@ -98,58 +114,19 @@ namespace SolarPower.Models
|
|||||||
public string EndTime { get; set; }
|
public string EndTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public class OperationRecode : Created
|
||||||
/// 運維作業記錄的搜尋條件
|
|
||||||
/// </summary>
|
|
||||||
public class PostOperationRecodeFilter
|
|
||||||
{
|
{
|
||||||
public List<int> CityIds { get; set; } //縣市編號
|
private string startTime, endTime, finishTime, workTime;
|
||||||
public List<int> PowerStationIds { get; set; } //電站編號
|
public int Id { get; set; }
|
||||||
public byte WorkType { get; set; } //工作項目
|
public string FormId { get; set; }
|
||||||
public string Range { get; set; } //取得搜尋範圍
|
public string SerialNumber { get; set; }
|
||||||
}
|
public int PowerStationId { get; set; }
|
||||||
|
public string PowerStationName { get; set; }
|
||||||
/// <summary>
|
public byte WorkType { get; set; }
|
||||||
/// 運維作業記錄的表單
|
public string ErrorCode { get; set; }
|
||||||
/// </summary>
|
public string FixDo { get; set; }
|
||||||
public class OperationRecodeDataTable
|
public byte Status { get; set; }
|
||||||
{
|
public int WorkPersonId { get; set; }
|
||||||
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
|
public string StartTime
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -180,6 +157,94 @@ namespace SolarPower.Models
|
|||||||
}
|
}
|
||||||
set { endTime = value; }
|
set { endTime = value; }
|
||||||
} // 結束時間
|
} // 結束時間
|
||||||
|
public string FinishTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(finishTime))
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime(finishTime).ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set { finishTime = value; }
|
||||||
|
} // 完成時間
|
||||||
|
public string WorkTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(workTime))
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime(workTime).ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set { workTime = value; }
|
||||||
|
} // 工作時間
|
||||||
|
public string Notice { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public List<OperationRecodeFile> RecodeFiles { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OperationRecodeFile : Created
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int RecordId { get; set; }
|
||||||
|
public string FileName { 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 : OperationRecode
|
||||||
|
{
|
||||||
|
public string WorkTypeText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
||||||
|
{
|
||||||
|
{ 0, "清洗"},
|
||||||
|
{ 1, "巡檢"},
|
||||||
|
{ 2, "維修"},
|
||||||
|
};
|
||||||
|
|
||||||
|
return pairs[WorkType];
|
||||||
|
}
|
||||||
|
} //工作項目名稱
|
||||||
|
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 OperationPredict
|
public string OperationPredict
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -187,7 +252,38 @@ namespace SolarPower.Models
|
|||||||
return StartTime + " ~ " + EndTime;
|
return StartTime + " ~ " + EndTime;
|
||||||
}
|
}
|
||||||
} //本次作業預計
|
} //本次作業預計
|
||||||
public string FileList { get; set; } //本次作業預計
|
public string FileList { get; set; } //檔案顯示
|
||||||
public string FinishTime { get; set; } //本次作業預計
|
}
|
||||||
|
|
||||||
|
public class PostOperationRecode
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public byte WorkType { get; set; }
|
||||||
|
public string ErrorCode { get; set; }
|
||||||
|
public string FixDo { get; set; }
|
||||||
|
public byte Status { get; set; }
|
||||||
|
public int WorkPersonId { get; set; }
|
||||||
|
public string StartTime { get; set; }//開始時間
|
||||||
|
public string EndTime { get; set; } // 結束時間
|
||||||
|
public string FinishTime { get; set; } // 完成時間
|
||||||
|
public string WorkTime { get; set; } // 工作時間
|
||||||
|
public string Notice { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public IFormFile[] RecodeFiles { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateOperationRecode : Updated
|
||||||
|
{
|
||||||
|
public string FormId { get; set; }
|
||||||
|
public string SerialNumber { get; set; }
|
||||||
|
public string ErrorCode { get; set; }
|
||||||
|
public string FixDo { get; set; }
|
||||||
|
public byte Status { get; set; }
|
||||||
|
public int WorkPersonId { get; set; }
|
||||||
|
public string FinishTime { get; set; } // 完成時間
|
||||||
|
public string WorkTime { get; set; } // 工作時間
|
||||||
|
public string Notice { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -467,4 +467,10 @@ namespace SolarPower.Models.PowerStation
|
|||||||
public int Amount { get; set; }
|
public int Amount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OperationPersonnelSelectItemList
|
||||||
|
{
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,15 +183,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = @$"SELECT
|
var sql = @$"SELECT
|
||||||
|
opr.*,
|
||||||
ps.Name AS PowerStationName,
|
ps.Name AS PowerStationName,
|
||||||
opr.FormId,
|
u.Name AS WorkPersonName
|
||||||
opr.WorkType,
|
|
||||||
opr.FixDO,
|
|
||||||
opr.Status,
|
|
||||||
u.Name AS WorkPersonName,
|
|
||||||
opr.StartTime,
|
|
||||||
opr.EndTime,
|
|
||||||
opr.FinishTime
|
|
||||||
FROM operation_record opr
|
FROM operation_record opr
|
||||||
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||||
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
||||||
@ -213,15 +207,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
sql += @" AND opr.WorkType IN (0, 1)";
|
sql += @" AND opr.WorkType IN (0, 1)";
|
||||||
sql += @" UNION";
|
sql += @" UNION";
|
||||||
sql += @" SELECT
|
sql += @" SELECT
|
||||||
|
opr.*,
|
||||||
ps.Name AS PowerStationName,
|
ps.Name AS PowerStationName,
|
||||||
opr.FormId,
|
u.Name AS WorkPersonName
|
||||||
opr.WorkType,
|
|
||||||
opr.FixDO,
|
|
||||||
opr.Status,
|
|
||||||
u.Name AS WorkPersonName,
|
|
||||||
opr.StartTime,
|
|
||||||
opr.EndTime,
|
|
||||||
opr.FinishTime
|
|
||||||
FROM operation_record opr
|
FROM operation_record opr
|
||||||
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||||
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
||||||
@ -240,5 +228,150 @@ namespace SolarPower.Repository.Implement
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 透過Id,取得單一筆運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<OperationRecode> GetOneOperationRecodeAsync(int id)
|
||||||
|
{
|
||||||
|
OperationRecode result;
|
||||||
|
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @$"SELECT opr.*, ps.Name AS PowerStationName
|
||||||
|
FROM operation_record opr
|
||||||
|
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||||
|
WHERE opr.Deleted = 0 AND opr.Id = @Id";
|
||||||
|
|
||||||
|
result = await conn.QueryFirstOrDefaultAsync<OperationRecode>(sql, new { Id = id });
|
||||||
|
|
||||||
|
if(result != null)
|
||||||
|
{
|
||||||
|
//取得圖片 or 檔案
|
||||||
|
var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
||||||
|
|
||||||
|
result.RecodeFiles = (await conn.QueryAsync<OperationRecodeFile>(sql_file, new { RecordId = result.Id })).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增一筆運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> AddOneOperationRecodeAsync(OperationRecode entity, List<string> properties)
|
||||||
|
{
|
||||||
|
var id = 0;
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
using (var trans = conn.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = GenerateInsertQueryWithCustomTable(properties, "operation_record");
|
||||||
|
|
||||||
|
sql += "SELECT LAST_INSERT_ID();";
|
||||||
|
|
||||||
|
id = (await conn.QueryAsync<int>(sql, entity, trans)).Single();
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <param name="db_name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List<string> properties)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
using (var trans = conn.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = GenerateUpdateQueryWithCustomTable(properties, "operation_record");
|
||||||
|
await conn.ExecuteAsync(sql, entity, trans);
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增運維作業記錄的檔案
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = GenerateInsertQueryWithCustomTable(properties, "operation_record_file");
|
||||||
|
|
||||||
|
count = await conn.ExecuteAsync(sql, entity);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -343,7 +343,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增 土地房屋資訊
|
/// 取得 土地房屋資訊
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="db_name"></param>
|
/// <param name="db_name"></param>
|
||||||
@ -1361,5 +1361,28 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
return powerstation;
|
return powerstation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId)
|
||||||
|
{
|
||||||
|
List<OperationPersonnelSelectItemList> result;
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @$"SELECT u.Id AS Value, u.Name AS Text
|
||||||
|
FROM power_station_operation_personnel op
|
||||||
|
LEFT JOIN user u ON op.UserId = u.Id
|
||||||
|
WHERE op.Deleted = 0 AND op.PowerStationId = @PowerStationId";
|
||||||
|
|
||||||
|
result = (await conn.QueryAsync<OperationPersonnelSelectItemList>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -519,14 +519,19 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// <param name="Table_name"></param>
|
/// <param name="Table_name"></param>
|
||||||
/// <param name="where"></param>
|
/// <param name="where"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<string> GetCurrentSerialNumber(string Table_name, string where)
|
public async Task<string> GetCurrentSerialNumber(string Table_name, string where = "")
|
||||||
{
|
{
|
||||||
string Num;
|
string Num;
|
||||||
using IDbConnection conn = _databaseHelper.GetConnection();
|
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||||
conn.Open();
|
conn.Open();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = $"SELECT SerialNumber FROM {Table_name} WHERE {where} ORDER BY SerialNumber DESC";
|
var sql = @$"SELECT SerialNumber FROM {Table_name}";
|
||||||
|
if (!string.IsNullOrEmpty(where))
|
||||||
|
{
|
||||||
|
sql += $" WHERE {where}";
|
||||||
|
}
|
||||||
|
sql += " ORDER BY SerialNumber DESC";
|
||||||
Num = await conn.QueryFirstOrDefaultAsync<string>(sql);
|
Num = await conn.QueryFirstOrDefaultAsync<string>(sql);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -22,6 +22,37 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter);
|
Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 透過Id,取得單一筆運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<OperationRecode> GetOneOperationRecodeAsync(int id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增一筆運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> AddOneOperationRecodeAsync(OperationRecode entity, List<string> properties);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改運維作業記錄
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List<string> properties);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增運維作業記錄的檔案
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="properties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,10 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<AreaSelectItemList>> GetAreaSelectOptionListAsync(int cityId);
|
Task<List<AreaSelectItemList>> GetAreaSelectOptionListAsync(int cityId);
|
||||||
|
|
||||||
|
Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過編號取得,縣市資訊
|
/// 透過編號取得,縣市資訊
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -95,6 +95,6 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="Table_name"></param>
|
/// <param name="Table_name"></param>
|
||||||
/// <param name="where"></param>
|
/// <param name="where"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<String> GetCurrentSerialNumber(string Table_name, string where);
|
Task<String> GetCurrentSerialNumber(string Table_name, string where = "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
<span class="fal fa-file-excel mr-1"></span>
|
<span class="fal fa-file-excel mr-1"></span>
|
||||||
匯出
|
匯出
|
||||||
</button>
|
</button>
|
||||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" data-toggle="modal" data-target="#companyrule">
|
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" onclick="AddRecode()">
|
||||||
<span class="fal fa-plus mr-1"></span>
|
<span class="fal fa-plus mr-1"></span>
|
||||||
維修單
|
維修單
|
||||||
</a>
|
</a>
|
||||||
@ -56,9 +56,9 @@
|
|||||||
<th>電廠</th>
|
<th>電廠</th>
|
||||||
<th>表單號</th>
|
<th>表單號</th>
|
||||||
<th>項目</th>
|
<th>項目</th>
|
||||||
<th>類型</th>
|
<th>維修項目</th>
|
||||||
<th>狀態</th>
|
<th>狀態</th>
|
||||||
<th>處理人員</th>
|
<th>執行人員</th>
|
||||||
<th>本次作業預計</th>
|
<th>本次作業預計</th>
|
||||||
<th>照片</th>
|
<th>照片</th>
|
||||||
<th>完成時間</th>
|
<th>完成時間</th>
|
||||||
@ -66,75 +66,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -142,12 +73,172 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="recode-form-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title">
|
||||||
|
<span class="main-title"></span><span class="sub-title"></span>
|
||||||
|
</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 id="recode-form">
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="power_station_select_modal">電站</label>
|
||||||
|
<select class="form-control" id="power_station_select_modal">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="work_time_modal">作業日期</label>
|
||||||
|
<input class="form-control" id="work_time_modal" type="date" name="work_time_modal" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="example-select">狀態</label>
|
||||||
|
<div>
|
||||||
|
<div class="custom-control custom-radio custom-control-inline">
|
||||||
|
<input type="radio" class="custom-control-input ml-auto" id="status_none_complete" name="status_modal" value="0" />
|
||||||
|
<label class="custom-control-label" for="status_none_complete">未完成</label>
|
||||||
|
</div>
|
||||||
|
<div class="custom-control custom-radio custom-control-inline">
|
||||||
|
<input type="radio" class="custom-control-input ml-auto" id="status_complete" name="status_modal" value="1" />
|
||||||
|
<label class="custom-control-label" for="status_complete">完成</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="work_person_select_modal">執行人員</label>
|
||||||
|
<select class="form-control" id="work_person_select_modal">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3 fix-div">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="error_code_modal">異常編號</label>
|
||||||
|
<input class="form-control" id="error_code_modal" type="text" name="error_code_modal" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="fix_do_modal">維修項目</label>
|
||||||
|
<input class="form-control" id="fix_do_modal" type="text" name="fix_do_modal" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="notice_textarea_modal">巡檢注意事項</label>
|
||||||
|
<textarea class="form-control" id="notice_textarea_modal" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="description_textarea_modal">結果描述</label>
|
||||||
|
<textarea class="form-control" id="description_textarea_modal" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-2">
|
||||||
|
<p>檔案上傳</p>
|
||||||
|
</div>
|
||||||
|
<div id="recode_files_div" class="col-10">
|
||||||
|
<div class="row align-items-center"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row px-3">
|
||||||
|
<form id="recode-file-div" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
|
||||||
|
@*<div class="fallback">
|
||||||
|
<input type="file" multiple />
|
||||||
|
</div>*@
|
||||||
|
<div class="dz-message needsclick">
|
||||||
|
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
|
||||||
|
<span class="text-uppercase">將圖片拖曳至這裡或點擊選擇圖片.</span>
|
||||||
|
<br>
|
||||||
|
<span class="fs-sm text-muted">僅供預覽,並未實際上傳。</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="save-recode-btn" onclick="SaveRecode()">確定</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script>
|
<script>
|
||||||
var operationRecodeTable;
|
var operationRecodeTable;
|
||||||
var selected_id = 0;
|
var selected_id = 0; var selected_work_type = -1;
|
||||||
|
var recode;
|
||||||
|
var countOperationRecodeFile = 0;
|
||||||
|
var recodeFileDropzone;
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
//#region 預設載入該使用者可以選擇的電站
|
||||||
|
GetPowerStation();
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 切換電站時,載入該電站運維人員
|
||||||
|
$("#power_station_select_modal").change(function () {
|
||||||
|
|
||||||
|
//查詢該電站的運維人員
|
||||||
|
var url_power_station_operation_personnel = "/PowerStation/GetOperationPersonnelSelectOptionList";
|
||||||
|
|
||||||
|
send_data = {
|
||||||
|
PowerStationId: $(this).val()
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(url_power_station_operation_personnel, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#work_person_select_modal").empty();
|
||||||
|
if (rel.data.length > 0) {
|
||||||
|
|
||||||
|
$.each(rel.data, function (index, val) {
|
||||||
|
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (recode != null || recode != undefined) {
|
||||||
|
$("#work_person_select_modal").val(recode.workPersonId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region 運維作業記錄 DataTable
|
//#region 運維作業記錄 DataTable
|
||||||
operationRecodeTable = $("#operation_recode_table").DataTable({
|
operationRecodeTable = $("#operation_recode_table").DataTable({
|
||||||
"pageLength": 20,
|
"pageLength": 20,
|
||||||
@ -164,9 +255,11 @@
|
|||||||
}, {
|
}, {
|
||||||
"data": "formId"
|
"data": "formId"
|
||||||
}, {
|
}, {
|
||||||
"data": "WorkTypeText"
|
"data": "workTypeText"
|
||||||
}, {
|
}, {
|
||||||
"data": "fixDo"
|
"data": "fixDo"
|
||||||
|
}, {
|
||||||
|
"data": "statusText"
|
||||||
}, {
|
}, {
|
||||||
"data": "workPersonName"
|
"data": "workPersonName"
|
||||||
}, {
|
}, {
|
||||||
@ -200,6 +293,7 @@
|
|||||||
},
|
},
|
||||||
'createdRow': function (row, data, dataIndex) {
|
'createdRow': function (row, data, dataIndex) {
|
||||||
$(row).attr('data-id', data.id);
|
$(row).attr('data-id', data.id);
|
||||||
|
$(row).attr('data-work-type', data.workType);
|
||||||
},
|
},
|
||||||
"ajax": {
|
"ajax": {
|
||||||
"url": "/Operation/OperationRecodeList",
|
"url": "/Operation/OperationRecodeList",
|
||||||
@ -227,131 +321,39 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//#endregion
|
//#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 搜尋公司列表
|
//#region 新增維修單
|
||||||
function SearchCompany() {
|
function AddRecode() {
|
||||||
companyTable.ajax.reload();
|
|
||||||
}
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region 新增公司基本資料
|
|
||||||
function AddCompany() {
|
|
||||||
|
|
||||||
selected_id = 0;
|
selected_id = 0;
|
||||||
$("#company-modal .modal-title").html("公司基本資料 - 新增");
|
$("#recode-form-modal .modal-title .main-title").html("維修單");
|
||||||
$("#company-form").trigger("reset");
|
$("#recode-form-modal .modal-title .sub-title").html("");
|
||||||
|
$("#power_station_select_modal").attr("disabled", false);
|
||||||
|
$(".fix-div").show();
|
||||||
|
$("#recode-form").trigger("reset");
|
||||||
|
GetPowerStation();
|
||||||
|
|
||||||
$("#company-modal").modal();
|
$("#recode-form-modal").modal();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 編輯公司資料
|
//#region 編輯表單內容
|
||||||
$('#company_table').on("click", "button.edit-btn", function () {
|
$('#operation_recode_table').on("click", "a.edit-btn", function () {
|
||||||
|
|
||||||
$("#company-modal .modal-title").html("公司基本資料 - 編輯");
|
work_type = $(this).parents('tr').attr('data-work-type');
|
||||||
|
|
||||||
|
if (work_type == 0) {
|
||||||
|
$("#recode-form-modal .modal-title .main-title").html("清洗單 - ");
|
||||||
|
} else if (work_type == 1) {
|
||||||
|
$("#recode-form-modal .modal-title .main-title").html("巡檢單 - ");
|
||||||
|
} else {
|
||||||
|
$("#recode-form-modal .modal-title .main-title").html("維修單 - ");
|
||||||
|
}
|
||||||
|
|
||||||
selected_id = $(this).parents('tr').attr('data-id');
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
|
|
||||||
//取得單一公司基本資料
|
//取得單一記錄表單
|
||||||
var url = "/Company/GetOneCompany/";
|
var url = "/Operation/GetOneOperationRecode/";
|
||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
id: selected_id
|
id: selected_id
|
||||||
@ -363,50 +365,72 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#company_name_modal").val(rel.data.name);
|
recode = rel.data;
|
||||||
$("#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();
|
countOperationRecodeFile = recode.recodeFiles.length;
|
||||||
|
|
||||||
|
$("#recode-form-modal .modal-title .sub-title").html(recode.powerStationName);
|
||||||
|
|
||||||
|
$("#power_station_select_modal").val(recode.powerStationId).trigger('change');
|
||||||
|
$("#power_station_select_modal").attr("disabled", true);
|
||||||
|
|
||||||
|
$("#work_time_modal").val(recode.workTime);
|
||||||
|
var status = -1;
|
||||||
|
if (recode.status == 0 || recode.status == 2) {
|
||||||
|
status = 0;
|
||||||
|
} else if (recode.status == 1 || recode.status == 3) {
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
|
||||||
|
$('#work_person_select_modal').val(recode.workPersonId);
|
||||||
|
if (work_type != 2) {
|
||||||
|
$(".fix-div").hide();
|
||||||
|
} else {
|
||||||
|
$(".fix-div").show();
|
||||||
|
$("#error_code_modal").val(recode.errorCode);
|
||||||
|
$("#fix_do_modal").val(recode.fixDo);
|
||||||
|
}
|
||||||
|
$("#notice_textarea_modal").val(recode.notice);
|
||||||
|
$("#description_textarea_modal").val(recode.description);
|
||||||
|
|
||||||
|
var str = "";
|
||||||
|
|
||||||
|
RecodeFileBox = $("#recode_files_div > .row");
|
||||||
|
RecodeFileBox.empty();
|
||||||
|
recode.recodeFiles.forEach(function (value, index) {
|
||||||
|
CreateRecodeFileBox(RecodeFileBox, value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#recode-form-modal").modal();
|
||||||
}, 'json');
|
}, 'json');
|
||||||
|
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 公司資料表單驗證
|
//#region 表單驗證
|
||||||
$("#company-form").validate({
|
$("#recode-form").validate({
|
||||||
rules: {
|
rules: {
|
||||||
company_name_modal: {
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
company_taxIDNumber_modal: {
|
|
||||||
required: true,
|
|
||||||
maxlength: 8,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 儲存公司資料
|
//#region 儲存表單資料(未用到先註解)
|
||||||
function SaveComapny() {
|
function SaveRecode() {
|
||||||
|
|
||||||
if ($("#company-form").valid()) {
|
if ($("#recode-form").valid()) {
|
||||||
var url = "/Company/SaveCompany";
|
var url = "/Operation/SaveOperationRecode";
|
||||||
|
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
var logos = $('#company_logo_modal')[0].files;
|
|
||||||
|
|
||||||
formData.append("Id", selected_id);
|
formData.append("Id", selected_id);
|
||||||
formData.append("Name", $("#company_name_modal").val());
|
formData.append("PowerStationId", $("#power_station_select_modal").val());
|
||||||
formData.append("TaxIDNumber", $("#company_taxIDNumber_modal").val());
|
formData.append("WorkType", selected_work_type);
|
||||||
formData.append("Phone", $("#company_phone_modal").val());
|
formData.append("ErrorCode", $("#error_code_modal").val());
|
||||||
formData.append("Address", $("#company_address_modal").val());
|
formData.append("FixDo", $("#fix_do_modal").val());
|
||||||
formData.append("RegisterUpperLimit", $("#company_registerUpperLimit_modal").val());
|
formData.append("Status", $("input[name=status_modal]:checked").val());
|
||||||
if (logos.length > 0) {
|
formData.append("WorkPersonId", $("#work_person_select_modal").val());
|
||||||
formData.append("LogoFile", logos[0])
|
formData.append("WorkTime", $("#work_time_modal").val());
|
||||||
}
|
formData.append("Notice", $("#notice_textarea_modal").val());
|
||||||
|
formData.append("Description", $("#description_textarea_modal").val());
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -421,95 +445,101 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
var myDropzone = Dropzone.forElement("#recode-file-div");
|
||||||
$('#company-modal').modal('hide');
|
myDropzone.processQueue();
|
||||||
|
|
||||||
companyTable.ajax.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region 刪除公司
|
myDropzone.on("successmultiple", function (file, rel) {
|
||||||
$('#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") {
|
if (rel.code == "9999") {
|
||||||
toast_error(rel.msg);
|
$('#recode-form-modal').modal('hide');
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (rel.code == "9998") {
|
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
toast_ok(rel.msg);
|
||||||
companyTable.ajax.reload();
|
$('#recode-form-modal').modal('hide');
|
||||||
}, 'json');
|
recodeFileDropzone.removeAllFiles();
|
||||||
|
|
||||||
|
operationRecodeTable.ajax.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
//#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
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
$.post(url, send_data, function (rel) {
|
//#region 取得電站選單資料
|
||||||
|
function GetPowerStation() {
|
||||||
|
var url_power_station_select_option = "/Operation/GetPowerStationSelectOption";
|
||||||
|
$.get(url_power_station_select_option, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
$("#power_station_select_modal").empty();
|
||||||
$("#company-auth-modal").modal('hide');
|
|
||||||
|
|
||||||
companyAuthTable.ajax.reload();
|
$.each(rel.data, function (index, val) {
|
||||||
}, 'json');
|
$("#power_station_select_modal").append($("<option />").val(val.value).text(val.text));
|
||||||
|
});
|
||||||
|
|
||||||
|
//預設查詢第一個
|
||||||
|
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 表單檔案資料包含儲存
|
||||||
|
Dropzone.autoDiscover = false;
|
||||||
|
recodeFileDropzone = new Dropzone("#recode-file-div", {
|
||||||
|
url: "/Operation/SaveOperationRecodeFile",
|
||||||
|
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
|
||||||
|
autoProcessQueue: false,
|
||||||
|
parallelUploads: 5,
|
||||||
|
maxFiles: 5,
|
||||||
|
addRemoveLinks: true,
|
||||||
|
uploadMultiple: true,
|
||||||
|
dictRemoveFile: "移除",
|
||||||
|
init: function (e) {
|
||||||
|
|
||||||
|
var myDropzone = this;
|
||||||
|
|
||||||
|
myDropzone.on("sendingmultiple", function (file, xhr, data) {
|
||||||
|
if ((countOperationRecodeFile + myDropzone.files.length) > 5) {
|
||||||
|
toast_warning("檔案總數量不可超過 5 張");
|
||||||
|
myDropzone.removeFile(file);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
data.append("Id", selected_id);
|
||||||
|
data.append("RecodeFiles", file);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
function CreateRecodeFileBox(dom, value) {
|
||||||
|
var str = "";
|
||||||
|
str += '<div class="col-2">';
|
||||||
|
var split = value.fileName.split(".");
|
||||||
|
var excel_format = ["xls", "xlsx"];
|
||||||
|
var word_format = ["doc", "docx"];
|
||||||
|
if (split[split.length - 1].toLowerCase() == "pdf") {
|
||||||
|
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-pdf"></i></a>';
|
||||||
|
} else if (excel_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
|
||||||
|
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-excel"></i></a>';
|
||||||
|
} else if (word_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
|
||||||
|
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-word"></i></a>';
|
||||||
|
} else {
|
||||||
|
str += '<img src="' + value.fileName + '" width="100%"/>';
|
||||||
|
}
|
||||||
|
str += '</div>';
|
||||||
|
dom.append(str);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
@ -12,65 +12,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-image-card">
|
<div class="card-body" id="power-station-image-card">
|
||||||
<div class="row d-flex justify-content-between">
|
<div class="row d-flex justify-content-between">
|
||||||
@*<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="...">
|
|
||||||
<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right">
|
|
||||||
<i class="fal fa-times"></i>
|
|
||||||
</a>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>*@
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -106,65 +47,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-single-line-card">
|
<div class="card-body" id="power-station-single-line-card">
|
||||||
<div class="row d-flex justify-content-between">
|
<div class="row d-flex justify-content-between">
|
||||||
@*<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="...">
|
|
||||||
<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right">
|
|
||||||
<i class="fal fa-times"></i>
|
|
||||||
</a>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xl">
|
|
||||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
|
||||||
<img src="~/img/blank.gif" class="card-img-top" alt="...">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="custom-control custom-checkbox">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
|
||||||
<label class="custom-control-label" for="defaultUnchecked">卡片顯示圖</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>*@
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -172,7 +54,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form id="power-station-single-line-form" action="/upload" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
<form id="power-station-single-line-form" action="/upload" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
||||||
<div class="fallback">
|
<div class="fallback">
|
||||||
<input name="" type="file" multiple />
|
<input type="file" multiple />
|
||||||
</div>
|
</div>
|
||||||
<div class="dz-message needsclick">
|
<div class="dz-message needsclick">
|
||||||
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
|
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
|
||||||
|
|||||||
@ -19,6 +19,9 @@ label.error {
|
|||||||
|
|
||||||
/* 隱藏圖片上傳 progress bar */
|
/* 隱藏圖片上傳 progress bar */
|
||||||
|
|
||||||
#power-station-images-form .dz-preview .dz-progress, #power-station-single-line-form .dz-preview .dz-progress {
|
#power-station-images-form .dz-preview .dz-progress,
|
||||||
|
#power-station-single-line-form .dz-preview .dz-progress,
|
||||||
|
#recode-file-div .dz-preview .dz-progress
|
||||||
|
{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user