電站javascript

This commit is contained in:
桂任 林 2021-06-14 15:35:02 +08:00
parent 7e9614c6ad
commit cf765a6699
10 changed files with 352 additions and 36 deletions

View File

@ -86,6 +86,7 @@ namespace SolarPower.Controllers
} }
HttpContext.Session.SetString("MyAccount", edFunction.AESEncrypt(user.Account)); //將帳號透過AES加密 HttpContext.Session.SetString("MyAccount", edFunction.AESEncrypt(user.Account)); //將帳號透過AES加密
HttpContext.Session.SetString("CompanyId", edFunction.AESEncrypt(user.CompanyId.ToString())); //將公司id透過AES加密
return RedirectToAction("Index", "User"); return RedirectToAction("Index", "User");

View File

@ -1,4 +1,11 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SolarPower.Models;
using SolarPower.Models.User;
using SolarPower.Repository.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -6,16 +13,54 @@ using System.Threading.Tasks;
namespace SolarPower.Controllers namespace SolarPower.Controllers
{ {
public class PowerStationController : Controller public class PowerStationController : MyBaseController<PowerStationController>
{ {
private readonly IUserRepository userRepository;
public PowerStationController(IUserRepository userRepository) : base()
{
this.userRepository = userRepository;
}
public IActionResult Index() public IActionResult Index()
{ {
return View(); return View();
} }
public IActionResult Add()
{
return View("~/Views/PowerStation/PowerStationAdd.cshtml");
}
public IActionResult Edit() public IActionResult Edit()
{ {
return View("~/Views/PowerStation/PowerStationEdit.cshtml"); return View("~/Views/PowerStation/PowerStationEdit.cshtml");
} }
/// <summary>
/// 取得下拉式公司選單須為Deleted: 0
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<ApiResult<List<UserSelectItemList>>> GetUserSelectOptionListAsync()
{
ApiResult<List<UserSelectItemList>> apiResult = new ApiResult<List<UserSelectItemList>>();
try
{
EDFunction edFunction = new EDFunction();
var companyId= Convert.ToInt32(edFunction.AESDecrypt(HttpContext.Session.GetString("CompanyId"))); //將公司id透過AES解密
var userSelectItemLists = await userRepository.GetUserSelectOptionListAsync(companyId);
apiResult.Code = "0000";
apiResult.Data = userSelectItemLists;
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
} }
} }

View File

@ -130,4 +130,11 @@ namespace SolarPower.Models.User
public string Phone { get; set; } //手機 public string Phone { get; set; } //手機
} }
public class UserSelectItemList
{
public string Text { get; set; }
public string Value { get; set; }
}
} }

View File

@ -277,5 +277,33 @@ namespace SolarPower.Repository.Implement
return result; return result;
} }
} }
/// <summary>
/// 透過公司,查詢使用者列表,0為全部公司的所有人
/// </summary>
/// <param name="CompanyId"></param>
/// <returns></returns>
public async Task<List<UserSelectItemList>> GetUserSelectOptionListAsync(int companyId)
{
List<UserSelectItemList> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
var sql = $"SELECT Id AS Value, Name AS Text FROM {tableName} WHERE Deleted = 0";
if(companyId != 0)
{
sql+=@" AND CompanyId=@companyId";
}
result = (await conn.QueryAsync<UserSelectItemList>(sql, new { companyId = companyId })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
} }
} }

View File

@ -67,5 +67,12 @@ namespace SolarPower.Repository.Interface
/// <param name="filter"></param> /// <param name="filter"></param>
/// <returns></returns> /// <returns></returns>
Task<List<UserDateTable>> GetAllByFilterAsync(PostUserFilter filter); Task<List<UserDateTable>> GetAllByFilterAsync(PostUserFilter filter);
/// <summary>
/// 透過公司,查詢使用者列表,0為全部公司的所有人
/// </summary>
/// <param name="CompanyId"></param>
/// <returns></returns>
Task<List<UserSelectItemList>> GetUserSelectOptionListAsync(int CompanyId);
} }
} }

View File

@ -50,7 +50,7 @@
<div class="tab-pane fade show active" id="tab-newtaipei" role="tabpanel" aria-labelledby="tab-newtaipei"> <div class="tab-pane fade show active" id="tab-newtaipei" role="tabpanel" aria-labelledby="tab-newtaipei">
<div class="row mb-5 d-flex justify-content-between"> <div class="row mb-5 d-flex justify-content-between">
<div class="col-6"> <div class="col-6">
<a asp-controller="PowerStation" asp-action="Edit" class="btn btn-success waves-effect waves-themed mb-3"> <a asp-controller="PowerStation" asp-action="Add" class="btn btn-success waves-effect waves-themed mb-3">
<span class="fal fa-plus mr-1"></span> <span class="fal fa-plus mr-1"></span>
新增電站 新增電站
</a> </a>

View File

@ -0,0 +1,163 @@
<!-- Your main content goes below here: -->
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<div class="tab-content p-3">
<div class="row mb-5">
<div class="card border mb-g w-100">
<!-- notice the additions of utility paddings and display properties on .card-header -->
<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">
<!-- we wrap header title inside a div tag with utility padding -->
<div class="card-title font-weight-bold">電站基本資料</div>
<div class="text-right">
<a href="javascript:;" class="btn btn-sm btn-info ml-auto waves-effect waves-themed">
<span class="fal fa-cog mr-1"></span> 儲存
</a>
</div>
</div>
<div class="card-body">
<div class="row d-flex justify-content-between">
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_id">電站編號</label>
<input type="text" id="power_station_id" name="power_station_id" disabled="disabled" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_name">電站名稱</label>
<input type="text" id="power_station_name" name="power_station_name" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<p>是否為代管:</p>
<p class="color-info-600">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="IsEscrow" name="IsEscrow">
<label class="custom-control-label" for="IsEscrow" id="IsEscrowLabel">No</label>
</div>
</p>
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="ElectricityMeterAt">台電掛錶日</label>
<input type="date" id="ElectricityMeterAt" name="ElectricityMeterAt" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="EstimatedRecoveryTime">預計回收年限</label>
<input type="text" id="EstimatedRecoveryTime" name="EstimatedRecoveryTime" class="form-control">
</div>
</div>
<div class="row d-flex justify-content-between mb-5">
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="GeneratingCapacity">電廠發電容量</label>
<input type="text" id="GeneratingCapacity" name="GeneratingCapacity" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_operation_personnel">運維人員</label>
<br />
<select class="js-example-basic-multiple form-control" id="power_station_operation_personnel" multiple="multiple">
</select>
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="EscrowName">被代管公司</label>
<input type="text" id="EscrowName" name="EscrowName" class="form-control" disabled="disabled">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="PowerRate">授電費率</label>
<input type="text" id="PowerRate" name="PowerRate" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="Coordinate">座標</label>
<input type="text" id="Coordinate" name="Coordinate" class="form-control">
</div>
</div>
<div class="row">
<div class="col-xl-6">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">逆變器</h5>
<div class="row d-flex justify-content-between px-5">
<div class="col-xl-4">
<label class="form-label" for="InverterBrand">廠牌</label>
<input type="text" id="InverterBrand" name="InverterBrand" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="InverterProductModel">型號</label>
<input type="text" id="InverterProductModel" name="InverterProductModel" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="InverterAmount">數量</label>
<input type="text" id="InverterAmount" name="InverterAmount" class="form-control">
</div>
</div>
</div>
<div class="col-xl-6">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5>
<div class="row d-flex justify-content-between px-5">
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelBrand">廠牌</label>
<input type="text" id="PhotovoltaicPanelBrand" name="PhotovoltaicPanelBrand" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelSpecification">規格</label>
<input type="text" id="PhotovoltaicPanelSpecification" name="PhotovoltaicPanelSpecification" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelAmount">數量</label>
<input type="text" id="PhotovoltaicPanelAmount" name="PhotovoltaicPanelAmount" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelProductModel">型號</label>
<input type="text" id="PhotovoltaicPanelProductModel" name="PhotovoltaicPanelProductModel" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@section Scripts{
<script>
//#region 預先載入公司下拉式選單select_option
var url_user_select_option = "/PowerStation/GetUserSelectOptionList";
$.get(url_user_select_option, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#power_station_operation_personnel").empty();
$.each(rel.data, function (index, val) {
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
});
//預設查詢第一個
$("#power_station_operation_personnel").val($("#power_station_operation_personnel option:first").val());
});
//#endregion
$('.js-example-basic-multiple').select2();
$("#IsEscrow").click(function () {
if ($(this).prop("checked")) {
$('#IsEscrowLabel').html("Yes");
$("#EscrowName").attr('disabled', false)
} else {
$('#IsEscrowLabel').html("No");
$("#EscrowName").attr('disabled', true)
}
});
</script>
}

View File

@ -81,4 +81,42 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@section Scripts{
<script>
$(function () {
//#region 預先載入公司下拉式選單select_option
var url_user_select_option = "/PowerStation/GetUserSelectOptionList";
$.get(url_user_select_option, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#power_station_operation_personnel").empty();
$.each(rel.data, function (index, val) {
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
});
//預設查詢第一個
$("#power_station_operation_personnel").val($("#power_station_operation_personnel option:first").val());
});
//#endregion
$('.js-example-basic-multiple').select2();
});
$("#IsEscrow").click(function () {
if ($(this).prop("checked")) {
$('#IsEscrowLabel').html("Yes");
$("#EscrowName").attr('disabled', false)
} else {
$('#IsEscrowLabel').html("No");
$("#EscrowName").attr('disabled', true)
}
});
</script>
}

View File

@ -16,60 +16,68 @@
<div class="card-body"> <div class="card-body">
<div class="row d-flex justify-content-between"> <div class="row d-flex justify-content-between">
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>電站代碼 </p> <p id="power_station_id_text">電站代碼: </p>
<p class="color-info-600">PEP-NTP001</p> <label class="form-label" id="power_station_id_label" for="power_station_id">電站編號</label>
<input type="text" id="power_station_id" name="power_station_id" disabled="disabled" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>電站名稱:</p> <p id="power_station_name_text">電站名稱:</p>
<p class="color-info-600">新竹巨城站</p> <label class="form-label" id="power_station_name_label" for="power_station_name">電站名稱</label>
<input type="text" id="power_station_name" name="power_station_name" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>是否為代管 </p> <p>是否為代管 </p>
<p class="color-info-600"> <p class="color-info-600">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input type="radio" class="custom-control-input" id="customSwitch3radio" checked="" disabled="" name="defaultSwitchRadioExample2"> <input type="checkbox" class="custom-control-input" id="IsEscrow" name="IsEscrow" disabled="disabled">
<label class="custom-control-label" for="customSwitch3radio">Yes</label> <label class="custom-control-label" for="IsEscrow" id="IsEscrowLabel">No</label>
</div> </div>
</p> </p>
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>台電掛錶日 </p> <p id="ElectricityMeterAt_text">台電掛錶日 </p>
<p class="color-info-600">2018-12-26</p> <label class="form-label" id="ElectricityMeterAt_Label" for="ElectricityMeterAt">台電掛錶日</label>
<input type="date" id="ElectricityMeterAt" name="ElectricityMeterAt" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>預計回收年限:</p> <p id="EstimatedRecoveryTime_text">預計回收年限:</p>
<p class="color-info-600">20</p> <label class="form-label" id="EstimatedRecoveryTime_Label" for="EstimatedRecoveryTime">預計回收年限</label>
<input type="text" id="EstimatedRecoveryTime" name="EstimatedRecoveryTime" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>資料建立:</p> <p id="CreatedBy_text">資料建立:</pCreatedBy>
<p class="color-info-600">蜘蛛人</p>
</div> </div>
</div> </div>
<div class="row d-flex justify-content-between mb-5"> <div class="row d-flex justify-content-between mb-5">
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>電廠發電容量 <br>(kW)</p> <p id="GeneratingCapacity_text">電廠發電容量 <br>(kW)</p>
<p class="color-info-600">362.7</p> <label class="form-label" id="GeneratingCapacity_Label" for="GeneratingCapacity">電廠發電容量</label>
<input type="text" id="GeneratingCapacity" name="GeneratingCapacity" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>運維人員:</p> <p id="power_station_operation_personnel_text">運維人員:</p>
<p class="color-info-600">美國隊長<br>鋼鐵人</p> <select class="js-example-basic-multiple form-control" id="power_station_operation_personnel" multiple="multiple">
</select>
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>被代管公司 </p> <p id="EscrowName_text">被代管公司 </p>
<p class="color-info-600">台達電</p> <label class="form-label" id="EscrowName_Lable" for="EscrowName">被代管公司</label>
<input type="text" id="EscrowName" name="EscrowName" class="form-control" disabled="disabled">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>授電費率:</p> <p id="PowerRate_text">授電費率:</p>
<p class="color-info-600">PM060MW2_305</p> <label class="form-label" id="PowerRate_Label" for="PowerRate">授電費率</label>
<input type="text" id="PowerRate" name="PowerRate" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>座標:</p> <p id="Coordinate_Text">座標:</p>
<p class="color-info-600">25.0726625,<br>121.5725953</p> <label class="form-label" id="Coordinate_Label" for="Coordinate">座標</label>
<input type="text" id="Coordinate" name="Coordinate" class="form-control">
</div> </div>
<div class="col-xl-2 d-flex justify-content-center"> <div class="col-xl-2 d-flex justify-content-center">
<p>建立時間:</p> <p id="CreatedAt_Text">建立時間:</p>
<p class="color-info-600">2018-10-01 12:00</p>
</div> </div>
</div> </div>
@ -78,13 +86,19 @@
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">逆變器</h5> <h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">逆變器</h5>
<div class="row d-flex justify-content-between px-5"> <div class="row d-flex justify-content-between px-5">
<div class="col-xl-4"> <div class="col-xl-4">
<p>廠牌:<span class="color-info-600">AUO</span></p> <p id="InverterBrand_text">廠牌:<span class="color-info-600">AUO</span></p>
<label class="form-label" id="InverterBrand_Label" for="InverterBrand">廠牌</label>
<input type="text" id="InverterBrand" name="InverterBrand" class="form-control">
</div> </div>
<div class="col-xl-4"> <div class="col-xl-4">
<p>型號 <span class="color-info-600">PM060MW2_305</span></p> <p id="InverterProductModel_text">型號 <span class="color-info-600">PM060MW2_305</span></p>
<label class="form-label" id="InverterProductModel_Label" for="InverterProductModel">型號</label>
<input type="text" id="InverterProductModel" name="InverterProductModel" class="form-control">
</div> </div>
<div class="col-xl-4 text-right"> <div class="col-xl-4 text-right">
<p>數量:<span class="color-info-600">400</span></p> <p id="InverterAmount_text">數量:<span class="color-info-600">400</span></p>
<label class="form-label" id="InverterAmount_Label" for="InverterAmount">數量</label>
<input type="text" id="InverterAmount" name="InverterAmount" class="form-control">
</div> </div>
</div> </div>
</div> </div>
@ -92,16 +106,24 @@
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5> <h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5>
<div class="row d-flex justify-content-between px-5"> <div class="row d-flex justify-content-between px-5">
<div class="col-xl-4"> <div class="col-xl-4">
<p>廠牌:<span class="color-info-600">ABLYTEK</span></p> <p id="PhotovoltaicPanelBrand_text">廠牌:<span class="color-info-600">ABLYTEK</span></p>
<label class="form-label" id="PhotovoltaicPanelBrand_Label" for="PhotovoltaicPanelBrand">廠牌</label>
<input type="text" id="PhotovoltaicPanelBrand" name="PhotovoltaicPanelBrand" class="form-control">
</div> </div>
<div class="col-xl-4"> <div class="col-xl-4">
<p>規格 <span class="color-info-600">1640×992×40</span></p> <p id="PhotovoltaicPanelSpecification_text">規格 <span class="color-info-600">1640×992×40</span></p>
<label class="form-label" id="PhotovoltaicPanelSpecification_Label" for="PhotovoltaicPanelSpecification">規格</label>
<input type="text" id="PhotovoltaicPanelSpecification" name="PhotovoltaicPanelSpecification" class="form-control">
</div> </div>
<div class="col-xl-4 text-right"> <div class="col-xl-4 text-right">
<p>數量:<span class="color-info-600">1116</span></p> <p id="PhotovoltaicPanelAmount_text">數量:<span class="color-info-600">1116</span></p>
<label class="form-label" id="PhotovoltaicPanelAmount_Label" for="PhotovoltaicPanelAmount">數量</label>
<input type="text" id="PhotovoltaicPanelAmount" name="PhotovoltaicPanelAmount" class="form-control">
</div> </div>
<div class="col-xl-4"> <div class="col-xl-4">
<p>型號 <span class="color-info-600">6MN6A295</span></p> <p>型號 <span class="color-info-600" id="PhotovoltaicPanelProductModel_text">6MN6A295</span></p>
<label class="form-label" id="PhotovoltaicPanelProductModel_Label" for="PhotovoltaicPanelProductModel">型號</label>
<input type="text" id="PhotovoltaicPanelProductModel" name="PhotovoltaicPanelProductModel" class="form-control">
</div> </div>
</div> </div>
</div> </div>
@ -253,4 +275,4 @@
</div> </div>
</div> </div>

View File

@ -31,6 +31,7 @@
<link rel="stylesheet" media="screen, print" href="~/css/formplugins/dropzone/dropzone.css"> <link rel="stylesheet" media="screen, print" href="~/css/formplugins/dropzone/dropzone.css">
<!--Custome CSS--> <!--Custome CSS-->
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</head> </head>
<body class="mod-bg-1"> <body class="mod-bg-1">
@ -1153,6 +1154,10 @@
<!-- Custome JS --> <!-- Custome JS -->
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>
<!--Select2-->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
@*各頁面的JavaScript*@ @*各頁面的JavaScript*@
@RenderSection("Scripts", required: false) @RenderSection("Scripts", required: false)
</body> </body>