解決合併衝突
This commit is contained in:
commit
665078f6c6
@ -27,14 +27,18 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 取得電站Option
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="post"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<ActionResult> GetPowerStationSelectOption(int post)
|
public async Task<ActionResult> GetPowerStationSelectOption(int post)
|
||||||
{
|
{
|
||||||
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(post) ;
|
PowerStationIdLists = await operationRepository.GetPowerStationIdList(myUser.Id) ;
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = PowerStationIdLists;
|
apiResult.Data = PowerStationIdLists;
|
||||||
}
|
}
|
||||||
@ -53,5 +57,181 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 儲存計畫
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="post"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<string>> SaveOperationPlan(OperationCreatePlanModal post)
|
||||||
|
{
|
||||||
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var now = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
var finalid = await operationRepository.GetCurrentSerialNumber("operation_plan_create", $"PowerStationId = {post.PowerStationId} AND CreatedAt LIKE '%{now}%'");
|
||||||
|
var newSerialNumber = GetLastSerialNumber(finalid);
|
||||||
|
var OperationPlan = new OperationCreatePlan()
|
||||||
|
{
|
||||||
|
EmailType = post.EmailType,
|
||||||
|
ScheduleNum = post.ScheduleNum,
|
||||||
|
Description = post.Description,
|
||||||
|
WorkDay = post.WorkDay,
|
||||||
|
ScheduleType = post.ScheduleType,
|
||||||
|
SerialNumber = newSerialNumber,
|
||||||
|
StartTime = post.StartTime,
|
||||||
|
PowerStationId = post.PowerStationId,
|
||||||
|
Type = post.Type,
|
||||||
|
PlanId = DateTime.Now.ToString("yyyyMMdd") + newSerialNumber,
|
||||||
|
CreatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"EmailType",
|
||||||
|
"ScheduleNum",
|
||||||
|
"Description",
|
||||||
|
"WorkDay",
|
||||||
|
"ScheduleType",
|
||||||
|
"SerialNumber",
|
||||||
|
"StartTime",
|
||||||
|
"PowerStationId",
|
||||||
|
"Type",
|
||||||
|
"PlanId",
|
||||||
|
"CreatedBy"
|
||||||
|
};
|
||||||
|
await operationRepository.AddOperationPlan(OperationPlan, properties);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Msg = "新增成功";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 定時計畫datatable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ActionResult> OperationPlanTable(List<int> id)
|
||||||
|
{
|
||||||
|
List<OperationPlanTable> OperationPlanTable = new List<OperationPlanTable>();
|
||||||
|
ApiResult<List<OperationPlanTable>> apiResult = new ApiResult<List<OperationPlanTable>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
OperationPlanTable = await operationRepository.OperationPlanTable(id);
|
||||||
|
foreach (OperationPlanTable a in OperationPlanTable)
|
||||||
|
{
|
||||||
|
if(a.Type == 0)
|
||||||
|
{
|
||||||
|
a.TypeName = "清洗";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a.TypeName = "巡檢";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(a.ScheduleType == 0)
|
||||||
|
{
|
||||||
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "天" ;
|
||||||
|
}
|
||||||
|
else if (a.ScheduleType == 1)
|
||||||
|
{
|
||||||
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "周";
|
||||||
|
}
|
||||||
|
else if (a.ScheduleType == 2)
|
||||||
|
{
|
||||||
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "月";
|
||||||
|
}
|
||||||
|
else if (a.ScheduleType == 3)
|
||||||
|
{
|
||||||
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "季";
|
||||||
|
}
|
||||||
|
else if (a.ScheduleType == 4)
|
||||||
|
{
|
||||||
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "年";
|
||||||
|
}
|
||||||
|
|
||||||
|
a.StartTimeString = a.StartTime.ToString("yyyy-MM-dd");
|
||||||
|
var crst = a.CreatedAt.Split(" ");
|
||||||
|
a.CreateTimeString = crst[0];
|
||||||
|
|
||||||
|
if(a.EmailType == 0)
|
||||||
|
{
|
||||||
|
a.EmailTypeName = "當天";
|
||||||
|
}
|
||||||
|
else if(a.EmailType == 1)
|
||||||
|
{
|
||||||
|
a.EmailTypeName = "前一天";
|
||||||
|
}
|
||||||
|
else if (a.EmailType == 2)
|
||||||
|
{
|
||||||
|
a.EmailTypeName = "前兩天";
|
||||||
|
}
|
||||||
|
else if (a.EmailType == 3)
|
||||||
|
{
|
||||||
|
a.EmailTypeName = "前三天";
|
||||||
|
}
|
||||||
|
|
||||||
|
a.Function = @"
|
||||||
|
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||||
|
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Data = OperationPlanTable;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
}
|
||||||
|
var result = Json(new
|
||||||
|
{
|
||||||
|
data = apiResult
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 刪除定時計畫
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<string>> DeleteOneOperationPlan(int Id)
|
||||||
|
{
|
||||||
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
OperationCreatePlan operation = new OperationCreatePlan();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
operation = await operationRepository.GetOneOperation(Id);
|
||||||
|
|
||||||
|
if (operation == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9998";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
await operationRepository.DeleteOneOtherTable(Id, "operation_plan_create");
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Msg = "刪除成功";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + Id);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace SolarPower.Helper
|
|||||||
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
||||||
|
|
||||||
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
||||||
var connStr = @"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;";
|
var connStr = @"server=127.0.0.1;port=3308;database=solar_power;user=root;password=00000000;charset=utf8;";
|
||||||
|
|
||||||
this._connectionString = connStr;
|
this._connectionString = connStr;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,6 @@ namespace SolarPower.Helper
|
|||||||
public IDbConnection GetConnection()
|
public IDbConnection GetConnection()
|
||||||
{
|
{
|
||||||
var conn = new MySqlConnection(this._connectionString);
|
var conn = new MySqlConnection(this._connectionString);
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,4 +26,34 @@ namespace SolarPower.Models
|
|||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
}
|
}
|
||||||
|
public class OperationCreatePlanModal : Created
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public int Type { get; set; }
|
||||||
|
public int ScheduleNum { get; set; }
|
||||||
|
public int ScheduleType { get; set; }
|
||||||
|
public int WorkDay { get; set; }
|
||||||
|
public DateTime StartTime { get; set; }
|
||||||
|
public DateTime EndTime { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public int EmailType { get; set; }
|
||||||
|
}
|
||||||
|
public class OperationCreatePlan : OperationCreatePlanModal
|
||||||
|
{
|
||||||
|
public string PlanId { get; set; }
|
||||||
|
public string SerialNumber { get; set; }
|
||||||
|
}
|
||||||
|
public class OperationPlanTable : OperationCreatePlan
|
||||||
|
{
|
||||||
|
public string TypeName { get; set; }
|
||||||
|
public string PowerStationName { get; set; }
|
||||||
|
public string Schedule { get; set; }
|
||||||
|
public string EmailTypeName { get; set; }
|
||||||
|
public string CreatedPerson { get; set; }
|
||||||
|
public string Function { get; set; }//功能
|
||||||
|
public string ScheduleDay { get; set; }
|
||||||
|
public string StartTimeString { get; set; }
|
||||||
|
public string CreateTimeString { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = @$"SELECT tn.Id AS Value, tn.Name AS Text FROM {tableName} tn LEFT JOIN power_station_operation_personnel pp
|
var sql = @$"SELECT tn.Id AS Value, tn.Name AS Text FROM power_station tn LEFT JOIN power_station_operation_personnel pp
|
||||||
ON tn.Id=pp.PowerStationId
|
ON tn.Id=pp.PowerStationId
|
||||||
WHERE pp.UserId = @userid";
|
WHERE pp.UserId = @userid";
|
||||||
result = (await conn.QueryAsync<PowerStationIdList>(sql, new { userid = UserId })).ToList();
|
result = (await conn.QueryAsync<PowerStationIdList>(sql, new { userid = UserId })).ToList();
|
||||||
@ -35,5 +35,86 @@ namespace SolarPower.Repository.Implement
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = GenerateInsertQuery(properties);
|
||||||
|
|
||||||
|
await conn.ExecuteAsync(sql, OperationPlan);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id)
|
||||||
|
{
|
||||||
|
List<OperationPlanTable> result;
|
||||||
|
var count = 0;
|
||||||
|
string Wheresql = "oc.PowerStationId = ";
|
||||||
|
foreach (int too in id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(count == id.Count-1)
|
||||||
|
{
|
||||||
|
Wheresql += too.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Wheresql += too.ToString() + " OR oc.PowerStationId = ";
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @$"SELECT *,ps.Name AS PowerStationName ,us.Name AS CreatedPerson FROM operation_plan_create oc LEFT JOIN power_station ps
|
||||||
|
ON oc.PowerStationId = ps.Id LEFT JOIN user us
|
||||||
|
ON us.Id = oc.CreatedBy WHERE {Wheresql} AND oc.Deleted = 0";
|
||||||
|
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<OperationCreatePlan> GetOneOperation(int id)
|
||||||
|
{
|
||||||
|
OperationCreatePlan result;
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @"SELECT * FROM operation_plan_create WHERE Deleted =0 AND Id = @Id";
|
||||||
|
|
||||||
|
result = await conn.QueryFirstOrDefaultAsync<OperationCreatePlan>(sql, new { Id = id });
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -477,5 +477,31 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
return updateQuery.ToString();
|
return updateQuery.ToString();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 取資料庫當前流水號
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Table_name"></param>
|
||||||
|
/// <param name="where"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> GetCurrentSerialNumber(string Table_name, string where)
|
||||||
|
{
|
||||||
|
string Num;
|
||||||
|
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $"SELECT SerialNumber FROM {Table_name} WHERE {where} ORDER BY SerialNumber DESC";
|
||||||
|
Num = await conn.QueryFirstOrDefaultAsync<string>(sql);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return Num;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SolarPower.Repository.Interface
|
namespace SolarPower.Repository.Interface
|
||||||
{
|
{
|
||||||
public interface IOperationRepository
|
public interface IOperationRepository : IRepositoryBase<Operation>
|
||||||
{
|
{
|
||||||
Task<List<PowerStationIdList>> GetPowerStationIdList(int UserId);
|
Task<List<PowerStationIdList>> GetPowerStationIdList(int UserId);
|
||||||
|
Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
|
||||||
|
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id);
|
||||||
|
Task<OperationCreatePlan> GetOneOperation(int id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,5 +81,12 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> GetOneVariableByName(string name);
|
Task<string> GetOneVariableByName(string name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取資料庫最後流水號
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Table_name"></param>
|
||||||
|
/// <param name="where"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<String> GetCurrentSerialNumber(string Table_name, string where);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@
|
|||||||
<div id="panel-5" class="panel">
|
<div id="panel-5" class="panel">
|
||||||
<div class="panel-container show">
|
<div class="panel-container show">
|
||||||
<div class="panel-content">
|
<div class="panel-content">
|
||||||
|
|
||||||
<div class="row mb-3 px-3">
|
<div class="row mb-3 px-3">
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<div class="btn-group btn-group-md">
|
<div class="btn-group btn-group-md">
|
||||||
@ -103,79 +102,28 @@
|
|||||||
<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" data-toggle="modal" data-target="#Operation-modal" onclick="AddOperationPlan()">
|
||||||
<span class="fal fa-plus mr-1"></span>
|
<span class="fal fa-plus mr-1"></span>
|
||||||
計劃
|
計劃
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="frame-wrap">
|
<div class="frame-wrap">
|
||||||
<table class="table table-bordered table-hover m-0 text-center">
|
<table id="OperationPlan_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
<tr>
|
<tr>
|
||||||
<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>email 通知</th>
|
<th>email 通知</th>
|
||||||
<th>建立人</th>
|
<th>建立人</th>
|
||||||
<th>建立時間</th>
|
<th>建立時間</th>
|
||||||
|
<th>功能</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<th scope="row">20210630003</th>
|
|
||||||
<td>巡檢</td>
|
|
||||||
<td>新竹交大站</td>
|
|
||||||
<td>每次5天內 / 1周</td>
|
|
||||||
<td>王小明</td>
|
|
||||||
<td>巡檢單01</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>2021-03-5</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">20210630003</th>
|
|
||||||
<td>清洗</td>
|
|
||||||
<td>新竹交大站</td>
|
|
||||||
<td>每次5天內 / 5周</td>
|
|
||||||
<td>鋼鐵人</td>
|
|
||||||
<td>清洗單02</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>2021-03-5</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">20210630003</th>
|
|
||||||
<td>清洗</td>
|
|
||||||
<td>新竹交大站</td>
|
|
||||||
<td>每次5天內 / 5周</td>
|
|
||||||
<td>鋼鐵人</td>
|
|
||||||
<td>清洗單02</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>2021-03-5</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -197,89 +145,90 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="row mb-3">
|
<form class="operation-form" id="Operation-form">
|
||||||
<div class="col-lg-6">
|
<div class="row mb-3">
|
||||||
<div class="form-group">
|
<div class="col-lg-6">
|
||||||
<label class="form-label" for="operation_powerStationselect_modal">電站名</label>
|
<div class="form-group">
|
||||||
<select class="form-control" id="operation_powerStationselect_modal">
|
<label class="form-label" for="operation_powerStationselect_modal">電站名</label>
|
||||||
</select>
|
<select class="form-control" id="operation_powerStationselect_modal">
|
||||||
</div>
|
</select>
|
||||||
</div>
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label" for="operation_type_modal">項目</label>
|
|
||||||
<select class="form-control" id="operation_type_modal">
|
|
||||||
<option value="0">清洗</option>
|
|
||||||
<option value="1">巡檢</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="row d-flex justify-content-start align-items-center">
|
|
||||||
<div class="col-4">自動排程 每</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" id="operation_scheduleNum_modal" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<select class="form-control" id="operation_scheduleType_modal" width="70" style="width: 70px">
|
|
||||||
<option value="0">天</option>
|
|
||||||
<option value="1">週</option>
|
|
||||||
<option value="2">月</option>
|
|
||||||
<option value="3">季</option>
|
|
||||||
<option value="4">年</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col">安排一次</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="col-lg-6">
|
||||||
<div class="row d-flex justify-content-start align-items-center">
|
<div class="form-group">
|
||||||
<div class="col-3">每次預期</div>
|
<label class="form-label" for="operation_type_modal">項目</label>
|
||||||
<div class="col">
|
<select class="form-control" id="operation_type_modal">
|
||||||
<input type="text" id="operation_workDay_modal" class="form-control">
|
<option value="0">清洗</option>
|
||||||
</div>
|
<option value="1">巡檢</option>
|
||||||
<div class="col">天內完成</div>
|
</select>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="row d-flex justify-content-start align-items-center">
|
|
||||||
<div class="col-3">開始時間</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" id="operation_startTime_modal" class="form-control" placeholder="2000-01-01">
|
|
||||||
</div>
|
|
||||||
<div class="col">~<font id="operation_endTime_modal">2021-06-30</font></div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="row mb-3">
|
||||||
<div class="form-group">
|
<div class="col-lg-6">
|
||||||
<label class="form-label" for="operation_description_modal">描述</label>
|
<div class="form-group">
|
||||||
<textarea class="form-control" id="operation_description_modal" rows="5"></textarea>
|
<div class="row d-flex justify-content-start align-items-center">
|
||||||
</div>
|
<div class="col-4">自動排程 每</div>
|
||||||
</div>
|
<div class="col">
|
||||||
</div>
|
<input type="number" id="operation_scheduleNum_modal" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<select class="form-control" id="operation_scheduleType_modal" width="70" style="width: 70px">
|
||||||
|
<option value="0">天</option>
|
||||||
|
<option value="1">週</option>
|
||||||
|
<option value="2">月</option>
|
||||||
|
<option value="3">季</option>
|
||||||
|
<option value="4">年</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col">安排一次</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="row d-flex justify-content-start align-items-center">
|
||||||
|
<div class="col-3">每次預期</div>
|
||||||
|
<div class="col">
|
||||||
|
<input type="number" id="operation_workDay_modal" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col">天內完成</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="row d-flex justify-content-start align-items-center">
|
||||||
|
<div class="col-3">開始時間</div>
|
||||||
|
<div class="col">
|
||||||
|
<input type="date" id="operation_startTime_modal" class="form-control" placeholder="2000-01-01">
|
||||||
|
</div>
|
||||||
|
<div class="col">~<span id="operation_endTime_modal"></span></div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
</div>
|
||||||
<div class="col-lg-6">
|
</div>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label class="form-label" for="operation_emailType_modal">email提醒</label>
|
<div class="col-lg-6">
|
||||||
<select class="form-control" id="operation_emailType_modal">
|
<div class="form-group">
|
||||||
<option value="0">當天</option>
|
<label class="form-label" for="operation_description_modal">描述</label>
|
||||||
<option value="1">前1天</option>
|
<textarea class="form-control" id="operation_description_modal" rows="5"></textarea>
|
||||||
<option value="2">前2天</option>
|
</div>
|
||||||
<option value="3">前3天</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="operation_emailType_modal">email提醒</label>
|
||||||
|
<select class="form-control" id="operation_emailType_modal">
|
||||||
|
<option value="0">當天</option>
|
||||||
|
<option value="1">前1天</option>
|
||||||
|
<option value="2">前2天</option>
|
||||||
|
<option value="3">前3天</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||||
<button type="button" class="btn btn-primary">確定</button>
|
<button type="button" class="btn btn-primary" onclick="SaveOperationPlan()">確定</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -288,26 +237,182 @@
|
|||||||
|
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script>
|
<script>
|
||||||
|
var selected_id = 0;
|
||||||
$(function () {
|
$(function () {
|
||||||
//#region 電站下拉式選單select_option
|
//#region 電站下拉式選單select_option
|
||||||
var url_operation_select_option = "/Operation/GetPowerStationSelectOption";
|
var url_operation_select_option = "/Operation/GetPowerStationSelectOption";
|
||||||
$.get(url_operation_select_option, function (rel) {
|
$.get(url_operation_select_option, function (rel) {
|
||||||
|
if (rel.data.code != "0000") {
|
||||||
|
toast_error(rel.data.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#operation_powerStationselect_modal").empty();
|
||||||
|
$.each(rel.data.data, function (index, val) {
|
||||||
|
$("#operation_powerStationselect_modal").append($("<option />").val(val.value).text(val.text));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
//#region 定時計畫列表 DataTable
|
||||||
|
OperationPlanTable = $("#OperationPlan_table").DataTable({
|
||||||
|
"pageLength": 20,
|
||||||
|
"paging": true,
|
||||||
|
"lengthChange": false,
|
||||||
|
"searching": false,
|
||||||
|
"ordering": true,
|
||||||
|
"info": true,
|
||||||
|
"autoWidth": false,
|
||||||
|
"responsive": true,
|
||||||
|
"order": [[9, "desc"]],
|
||||||
|
"columns": [{
|
||||||
|
"data": "planId"
|
||||||
|
}, {
|
||||||
|
"data": "typeName"
|
||||||
|
}, {
|
||||||
|
"data": "powerStationName"
|
||||||
|
}, {
|
||||||
|
"data": "schedule"
|
||||||
|
}, {
|
||||||
|
"data": "workDay"
|
||||||
|
}, {
|
||||||
|
"data": "startTimeString"
|
||||||
|
}, {
|
||||||
|
"data": "emailTypeName"
|
||||||
|
}, {
|
||||||
|
"data": "createdPerson"
|
||||||
|
}, {
|
||||||
|
"data": "createTimeString"
|
||||||
|
}, {
|
||||||
|
"data": "function"
|
||||||
|
}],
|
||||||
|
"columnDefs": [{
|
||||||
|
'targets': 1,
|
||||||
|
'searchable': false,
|
||||||
|
'orderable': false,
|
||||||
|
'className': 'dt-body-center'
|
||||||
|
}],
|
||||||
|
"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/OperationPlanTable",
|
||||||
|
"type": "POST",
|
||||||
|
"data": function (d) {
|
||||||
|
d.id = [1,2];
|
||||||
|
},
|
||||||
|
"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 新增計畫基本資料
|
||||||
|
function AddOperationPlan() {
|
||||||
|
|
||||||
|
selected_id = 0;
|
||||||
|
$("#Operation-modal .modal-title").html("定時計劃 - 新增");
|
||||||
|
$("#Operation-form").trigger("reset");
|
||||||
|
$("#Operation-modal").modal();
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
//#region 結束時間顯示
|
||||||
|
$('#operation_startTime_modal').change(function () {
|
||||||
|
var dat = new Date($('#operation_startTime_modal').val());
|
||||||
|
var day = new Date(dat.setDate(dat.getDate() + Number($('#operation_workDay_modal').val()))).toISOString().split("T");
|
||||||
|
document.getElementById("operation_endTime_modal").innerHTML = day[0];
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
//#region 儲存定時計畫資料
|
||||||
|
function SaveOperationPlan() {
|
||||||
|
var url = "/Operation/SaveOperationPlan";
|
||||||
|
|
||||||
|
var send_data = {
|
||||||
|
PowerStationId: $("#operation_powerStationselect_modal").val(),
|
||||||
|
Type: $("#operation_type_modal").val(),
|
||||||
|
ScheduleNum: $("#operation_scheduleNum_modal").val(),
|
||||||
|
ScheduleType: $("#operation_scheduleType_modal").val(),
|
||||||
|
WorkDay: $('#operation_workDay_modal').val(),
|
||||||
|
StartTime: $("#operation_startTime_modal").val(),
|
||||||
|
EndTime: $("#operation_endTime_modal").val(),
|
||||||
|
Description: $("#operation_description_modal").val(),
|
||||||
|
EmailType: $('#operation_emailType_modal').val()
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
toast_ok(rel.msg);
|
||||||
|
OperationPlanTable.ajax.reload();
|
||||||
|
$('#Operation-modal').modal('hide');
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
//#region 刪除定時計畫資料
|
||||||
|
$('#OperationPlan_table').on("click", "button.del-btn", function () {
|
||||||
|
|
||||||
$("#company_select").empty();
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
$("#company_select").append($("<option />").val(0).text("全部"));
|
Swal.fire(
|
||||||
|
{
|
||||||
$.each(rel.data, function (index, val) {
|
title: "刪除",
|
||||||
$("#company_select").append($("<option />").val(val.value).text(val.text));
|
text: "你確定是否刪除此筆資料?",
|
||||||
|
type: "warning",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "是",
|
||||||
|
cancelButtonText: "否"
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.value) {
|
||||||
|
//取得單一系統管理員
|
||||||
|
var url = "/Operation/DeleteOneOperationPlan/";
|
||||||
|
var send_data = {
|
||||||
|
Id: selected_id
|
||||||
|
}
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code == "9999") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toast_ok(rel.msg);
|
||||||
|
OperationPlanTable.ajax.reload();
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//預設查詢第一個
|
|
||||||
$("#company_select").val($("#company_select option:first").val()).trigger('change');
|
|
||||||
});
|
|
||||||
//#endregion
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user