Merge branch 'master' into Willy
This commit is contained in:
commit
68d7d98e52
@ -89,7 +89,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
|
||||
{ //如果身分為公司管理員 或 公司使用者,就只能看自己公司的資料
|
||||
post.SelectedCompanyId = myUser.CompanyId;
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.Role;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -40,7 +41,8 @@ namespace SolarPower.Controllers
|
||||
MapOverview mapOverview = new MapOverview();
|
||||
try
|
||||
{
|
||||
List<int> powerStationIds = new List<int>() { 1, 2, 3};
|
||||
|
||||
List<int> powerStationIds = await powerStationRepository.GetPowerStationIdsByUserRole(myUser);
|
||||
var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds);
|
||||
mapOverview.Today_kwh = overview.Today_kwh;
|
||||
mapOverview.Total_kwh = overview.Total_kwh;
|
||||
@ -86,13 +88,5 @@ namespace SolarPower.Controllers
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
//public async Task<ApiResult<MapOverview>> GetAllDate()
|
||||
//{
|
||||
// ApiResult<MapOverview> apiResult = new ApiResult<MapOverview>();
|
||||
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +151,9 @@ namespace SolarPower.Controllers
|
||||
stationOverview.Total_monery = 0;
|
||||
}
|
||||
|
||||
var powerStation = await powerStationRepository.GetOneAsync(post.Ids.First());
|
||||
|
||||
stationOverview.SolarType = powerStation.SolarType;
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = stationOverview;
|
||||
|
||||
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.User;
|
||||
using SolarPower.Repository.Interface;
|
||||
using SolarPower.Services.Interface;
|
||||
@ -22,12 +23,15 @@ namespace SolarPower.Controllers
|
||||
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly ISendEmailService sendEmailService;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private string logoPath = "/upload/company_logo/";
|
||||
public UserController(IUserRepository userRepository,
|
||||
ISendEmailService sendEmailService) : base()
|
||||
ISendEmailService sendEmailService,
|
||||
IPowerStationRepository powerStationRepository) : base()
|
||||
{
|
||||
this.userRepository = userRepository;
|
||||
this.sendEmailService = sendEmailService;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -497,5 +501,101 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<UserPowerStation>>> GetUserCompanyPowerStation(int id)
|
||||
{
|
||||
ApiResult<List<UserPowerStation>> apiResult = new ApiResult<List<UserPowerStation>>();
|
||||
|
||||
SimpleUser user = null;
|
||||
|
||||
try
|
||||
{
|
||||
user = await userRepository.GetOneSimpleUser(id);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
apiResult.Code = "9998";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
var companyPowerStation = await userRepository.GetCompanyPowerStationAsync(user.CompanyId, user.Id);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = companyPowerStation;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> SaveUserPowerStation(PostUserPowerStation post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
SimpleUser user = null;
|
||||
|
||||
try
|
||||
{
|
||||
user = await userRepository.GetOneSimpleUser(post.UserId);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
apiResult.Code = "9998";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //如果身分為公司管理員 或 公司使用者,就只能改自己公司的資料
|
||||
|
||||
if(user.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
|
||||
List<PowerStationOperationPersonnel> insertOperationPersonnels = new List<PowerStationOperationPersonnel>();
|
||||
|
||||
PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel();
|
||||
operationPersonnel.PowerStationId = post.PowerStationId;
|
||||
operationPersonnel.UserId = post.UserId;
|
||||
operationPersonnel.CreatedBy = myUser.Id;
|
||||
|
||||
insertOperationPersonnels.Add(operationPersonnel);
|
||||
|
||||
List<string> operationPersonnelProperties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"UserId",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1039,7 +1039,61 @@ ALTER TABLE `inverter`
|
||||
ALTER TABLE `device`
|
||||
ADD COLUMN `Enabled` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否啟用, 0:否 1:是' AFTER `PowerStationId`,
|
||||
ADD COLUMN `InstallDate` timestamp NULL DEFAULT NULL COMMENT '安裝日期' AFTER `ColName`,
|
||||
DROP COLUMN `Remark`,
|
||||
DROP COLUMN `Remark`;
|
||||
|
||||
|
||||
-- 各電站每天的逆變器歷史記錄 20210712
|
||||
CREATE TABLE `inverter_history_day` (
|
||||
`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`KWH` DOUBLE NULL DEFAULT NULL,
|
||||
`TODAYKWH` DOUBLE NULL DEFAULT NULL,
|
||||
`KWHKWP` DOUBLE NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`Id`) USING BTREE,
|
||||
INDEX `IDX_01` (`PowerStationId`) USING BTREE
|
||||
)
|
||||
COMMENT='各電站每天的逆變器歷史記錄'
|
||||
COLLATE='utf8mb4_unicode_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
-- 各電站每小時的逆變器歷史記錄 20210712
|
||||
CREATE TABLE `inverter_history_hour` (
|
||||
`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`KWH` DOUBLE NULL DEFAULT NULL,
|
||||
`TODAYKWH` DOUBLE NULL DEFAULT NULL,
|
||||
`KWHKWP` DOUBLE NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`Id`) USING BTREE,
|
||||
INDEX `IDX_01` (`PowerStationId`) USING BTREE
|
||||
)
|
||||
COMMENT='各電站每小時的逆變器歷史記錄'
|
||||
COLLATE='utf8mb4_unicode_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
-- 各電站每月的逆變器歷史記錄 20210712
|
||||
CREATE TABLE `inverter_history_month` (
|
||||
`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
|
||||
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||
`KWH` DOUBLE NULL DEFAULT NULL,
|
||||
`TODAYKWH` DOUBLE NULL DEFAULT NULL,
|
||||
`KWHKWP` DOUBLE NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`Id`) USING BTREE,
|
||||
INDEX `IDX_01` (`PowerStationId`) USING BTREE
|
||||
)
|
||||
COMMENT='各電站每月的逆變器歷史記錄'
|
||||
COLLATE='utf8mb4_unicode_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
|
||||
-- 新增模組溫度計溫度 20210712
|
||||
ALTER TABLE `pyrheliometer_history_day`
|
||||
|
||||
@ -54,6 +54,7 @@ namespace SolarPower.Models
|
||||
public class StationOverview : Overview
|
||||
{
|
||||
public byte IsShowMoney { get; set; } //是否顯示發電金額
|
||||
public byte SolarType { get; set; }
|
||||
public string UpdatedAt { get; set; } //畫面資料更新時間
|
||||
}
|
||||
|
||||
|
||||
@ -142,8 +142,11 @@ namespace SolarPower.Models.User
|
||||
public string PowerStationName { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string EscrowName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class PostUserPowerStation
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Role;
|
||||
|
||||
namespace SolarPower.Repository.Implement
|
||||
{
|
||||
@ -2146,7 +2147,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> UpdateInverter(Inverter entity, List<string> properties,string db_name)
|
||||
public async Task<int> UpdateInverter(Inverter entity, List<string> properties, string db_name)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -2248,7 +2249,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
List<string> sql_per_device = new List<string>();
|
||||
|
||||
foreach(var device in deviceInfos)
|
||||
foreach (var device in deviceInfos)
|
||||
{
|
||||
var str = @$"SELECT DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/ 1000), '%Y-%m-%d %H') AS TIMESTAMP, s.SITEID, AVG(s.{device.ColName}) AS SENSOR
|
||||
FROM {device.DBName}.{device.TableName} s
|
||||
@ -2534,7 +2535,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<InverterHistory>> CalcInverterHisyortHourData(string dateTime, string db_name ,string table_name)
|
||||
public async Task<List<InverterHistory>> CalcInverterHisyortHourData(string dateTime, string db_name, string table_name)
|
||||
{
|
||||
List<InverterHistory> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -2789,5 +2790,37 @@ namespace SolarPower.Repository.Implement
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<int>> GetPowerStationIdsByUserRole(MyUser myUser)
|
||||
{
|
||||
List<int> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = "";
|
||||
|
||||
if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
|
||||
{
|
||||
sql += @$"SELECT ps.Id FROM power_station ps WHERE ps.Deleted = 0 AND ComapnyId = @ComapnyId";
|
||||
}
|
||||
else if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser)
|
||||
{
|
||||
sql += @$"SELECT op.PowerStationId FROM power_station_operation_personnel op WHERE op.Deleted = 0 AND UserId = @UserId";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql += @$"SELECT ps.Id FROM power_station ps WHERE ps.Deleted = 0";
|
||||
}
|
||||
|
||||
result = (await conn.QueryAsync<int>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,11 +298,11 @@ namespace SolarPower.Repository.Implement
|
||||
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";
|
||||
if (companyId != 0)
|
||||
{
|
||||
sql += @" AND CompanyId=@companyId";
|
||||
}
|
||||
result = (await conn.QueryAsync<UserSelectItemList>(sql, new { companyId = companyId })).ToList();
|
||||
}
|
||||
@ -337,7 +337,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN power_station ps ON op.PowerStationId = ps.Id
|
||||
LEFT JOIN company c ON ps.CompanyId = c.Id
|
||||
WHERE op.Deleted = 0 AND op.UserId = @UserId";
|
||||
|
||||
|
||||
result = (await conn.QueryAsync<UserPowerStation>(sql, new { UserId = userId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -414,5 +414,33 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId)
|
||||
{
|
||||
List<UserPowerStation> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
ps.Id,
|
||||
ps.Code,
|
||||
ps.Name AS PowerStationName,
|
||||
CASE ps.IsEscrow WHEN 1 THEN CONCAT(ps.EscrowName, '(代管)')
|
||||
WHEN 0 THEN c.Name
|
||||
END AS EscrowName
|
||||
FROM power_station ps
|
||||
LEFT JOIN company c ON ps.CompanyId = c.Id
|
||||
WHERE ps.CompanyId = @CompanyId AND ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0)";
|
||||
|
||||
result = (await conn.QueryAsync<UserPowerStation>(sql, new { CompanyId = companyId, UserId = userId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,5 +520,7 @@ namespace SolarPower.Repository.Interface
|
||||
Task<int> AddInverterHistoryMonthList(List<InverterHistory> entity, List<string> properties);
|
||||
Task<int> UpdateInverterHistoryMonthList(List<InverterHistory> entity);
|
||||
|
||||
Task<List<int>> GetPowerStationIdsByUserRole(MyUser myUser);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,5 +95,12 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOneUserPowerStationAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得該公司的電站
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UserPowerStation>> GetCompanyPowerStationAsync(int companyId, int userId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +250,26 @@
|
||||
});
|
||||
|
||||
function initMap() {
|
||||
|
||||
|
||||
mapOverview.powerStations.forEach(function (item, index) {
|
||||
var contentString = '<div id="content">' +
|
||||
'<div id="siteNotice"></div>' +
|
||||
'<h1 id="firstHeading" class="firstHeading">' + item.name + '</h1>' +
|
||||
'<div id="bodyContent">' +
|
||||
'<div class="row">' +
|
||||
'<div class="col-12">' +
|
||||
'<div>發電量:' + item.today_kWh + '</div>'+
|
||||
'<div>日照度:' + item.today_irradiance + '</div>'+
|
||||
'<div>發電小時:' + item.solarHour + '</div>' +
|
||||
'<div>裝置容量:' + item.generatingCapacity + '</div>' +
|
||||
'<div>天氣:' + + '</div>'+
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
|
||||
if (item.coordinate != null) {
|
||||
var split = item.coordinate.split(',');
|
||||
if (split[0] == undefined || split[0] == null) {
|
||||
@ -260,7 +279,8 @@
|
||||
if (split[1] == undefined || split[1] == null) {
|
||||
split[1] = 122
|
||||
}
|
||||
locations.push({ lat: parseFloat(split[0]), lng: parseFloat(split[1]) })
|
||||
|
||||
locations.push([item.name, contentString, split[0], split[1]]); //format:[標籤名、infoWindow、緯度、經度]
|
||||
}
|
||||
});
|
||||
|
||||
@ -268,18 +288,28 @@
|
||||
zoom: 7,
|
||||
center: { lat: 23.5, lng: 123 },
|
||||
});
|
||||
|
||||
var infowindow = new google.maps.InfoWindow();
|
||||
// Create an array of alphabetical characters used to label the markers.
|
||||
const labels = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
// Add some markers to the map.
|
||||
// Note: The code uses the JavaScript Array.prototype.map() method to
|
||||
// create an array of markers based on a given "locations" array.
|
||||
// The map() method here has nothing to do with the Google Maps API.
|
||||
const markers = locations.map((location, i) => {
|
||||
return new google.maps.Marker({
|
||||
position: location,
|
||||
label: labels[i % labels.length],
|
||||
marker = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(location[2], location[3]),
|
||||
@*label: location[0],*@
|
||||
map: map
|
||||
});
|
||||
});
|
||||
|
||||
google.maps.event.addListener(marker, 'click', (function (marker, i) {
|
||||
return function () {
|
||||
infowindow.setContent(location[1]);
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
})(marker, i));
|
||||
|
||||
return marker;
|
||||
});
|
||||
// Add a marker clusterer to manage the markers.
|
||||
new MarkerClusterer(map, markers, {
|
||||
|
||||
@ -151,6 +151,20 @@
|
||||
$(".irradiance-card").show();
|
||||
}
|
||||
|
||||
if (stationOverview.solarType == 0) {
|
||||
$("#money-card-title").html("發電金額");
|
||||
$("#money-card-subtitle-total").html("總發電金額");
|
||||
$("#money-card-subtitle-avg").html("今日發電金額");
|
||||
} else if (stationOverview.solarType == 1) {
|
||||
$("#money-card-title").html("租金收入");
|
||||
$("#money-card-subtitle-total").html("總租金收入");
|
||||
$("#money-card-subtitle-avg").html("今日租金收入");
|
||||
} else {
|
||||
$("#money-card-title").html("省電費用");
|
||||
$("#money-card-subtitle-total").html("總省電費用");
|
||||
$("#money-card-subtitle-avg").html("今日省電費用");
|
||||
}
|
||||
|
||||
}, 'json');
|
||||
|
||||
//#region 載入電站圖片
|
||||
|
||||
@ -18,16 +18,16 @@
|
||||
</div>
|
||||
<div class="card money-card">
|
||||
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
|
||||
<h4 class="mb-0 font-weight-bold"><span class="fal fa-dollar-sign mr-1"></span> 發電金額</h4>
|
||||
<h4 class="mb-0 font-weight-bold"><span class="fal fa-dollar-sign mr-1"></span> <span id="money-card-title">發電金額</span></h4>
|
||||
<div class="ml-auto">NTD</div>
|
||||
</div>
|
||||
<div class="card-body" style="min-height: 148px;">
|
||||
<div class="d-flex justify-content-between">
|
||||
<p>總發金額</p>
|
||||
<p id="money-card-subtitle-total">總發金額</p>
|
||||
<p><span class="color-info-700" id="total_money">126,161.72</span></p>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between">
|
||||
<p>平均發電金額</p>
|
||||
<p id="money-card-subtitle-avg">平均發電金額</p>
|
||||
<p><span class="color-info-700" id="today_money">4,069.73</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -795,31 +795,13 @@
|
||||
|
||||
}, 'json');
|
||||
|
||||
var url = "/User/GetUserPowerStation"
|
||||
UpdateUserPowerStationTable(id, function (returnData) {
|
||||
if (returnData) {
|
||||
$("#add-user-power-station").attr("data-user-id", id);
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
$("#user-power-station-modal").modal();
|
||||
}
|
||||
|
||||
userPowerStationTable = $("#user-power-station-table > tbody");
|
||||
|
||||
userPowerStationTable.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
var str = "";
|
||||
str += "<tr>";
|
||||
str += "<td>" + value.code + "</td>";
|
||||
str += "<td>" + value.powerStationName + "</td>";
|
||||
str += "<td>" + value.escrowName + "</td>";
|
||||
str += "<td>" + '<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed del-user-power-station" data-id="' + value.id + '">刪除</button>' + "</td>";
|
||||
str += "</tr>";
|
||||
|
||||
userPowerStationTable.append(str);
|
||||
});
|
||||
|
||||
$("#user-power-station-modal").modal();
|
||||
}, 'json');
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@ -859,6 +841,104 @@
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 新增使用者管理電站
|
||||
function AddUserPowerStation(e) {
|
||||
|
||||
var user_id = $(e).attr("data-user-id");
|
||||
|
||||
var url = "/User/GetUserCompanyPowerStation";
|
||||
var send_data = {
|
||||
Id: user_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var companyPowerStationTable = $("#company-power-station-table");
|
||||
|
||||
companyPowerStationTable.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
var str = "";
|
||||
str += "<tr>";
|
||||
str += "<td>" + value.code + "</td>";
|
||||
str += "<td>" + value.powerStationName + "</td>";
|
||||
str += "<td>" + value.escrowName + "</td>";
|
||||
str += "<td>" + '<button type="button" class="btn btn-success btn-pills waves-effect waves-themed save-user-power-station" data-id="' + value.id + '" data-user-id="' + user_id + '">新增</button>' + "</td>";
|
||||
str += "</tr>";
|
||||
|
||||
companyPowerStationTable.append(str);
|
||||
});
|
||||
|
||||
$("#add-user-manager-station-modal").modal();
|
||||
|
||||
}, 'json');
|
||||
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 儲存使用者電站
|
||||
$("#company-power-station-table").on("click", "button.save-user-power-station", function () {
|
||||
selected_power_station_id = $(this).attr('data-id');
|
||||
selected_user_id = $(this).attr('data-user-id');
|
||||
var save_btn = $(this);
|
||||
|
||||
//取得單一系統管理員
|
||||
var url = "/User/SaveUserPowerStation/";
|
||||
var send_data = {
|
||||
PowerStationId: selected_power_station_id,
|
||||
UserId: selected_user_id
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
save_btn.parents("tr").remove();
|
||||
toast_ok(rel.msg);
|
||||
|
||||
UpdateUserPowerStationTable(selected_user_id);
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
|
||||
function UpdateUserPowerStationTable(user_id, callback) {
|
||||
var url = "/User/GetUserPowerStation";
|
||||
var send_data = {
|
||||
Id: user_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
callback(false);
|
||||
}
|
||||
|
||||
userPowerStationTable = $("#user-power-station-table > tbody");
|
||||
|
||||
userPowerStationTable.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
var str = "";
|
||||
str += "<tr>";
|
||||
str += "<td>" + value.code + "</td>";
|
||||
str += "<td>" + value.powerStationName + "</td>";
|
||||
str += "<td>" + value.escrowName + "</td>";
|
||||
str += "<td>" + '<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed del-user-power-station" data-id="' + value.id + '">刪除</button>' + "</td>";
|
||||
str += "</tr>";
|
||||
|
||||
userPowerStationTable.append(str);
|
||||
});
|
||||
|
||||
userTable.ajax.reload();
|
||||
callback(true);
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 角色管理Tab
|
||||
@ -1079,12 +1159,10 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
function bbb() {
|
||||
$("#bbb-modal").modal();
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveUser()">確定</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveUser()">確定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -125,7 +125,6 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
@ -144,18 +143,18 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-12"> <a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 " id="add-user-power-station" onclick="AddUserPowerStation(this)"><span class="fal fa-plus mr-1"></span> 增加管理電站</a> </div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" onclick="bbb()">取消</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">確定</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
@*<button type="button" class="btn btn-primary" data-dismiss="modal">確定</button>*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.Modal 人員電站資訊 -->
|
||||
|
||||
|
||||
<div class="modal fade" id="bbb-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<!-- Modal 新增人員管理電站 -->
|
||||
<div class="modal fade" id="add-user-manager-station-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -167,56 +166,24 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="user-form" id="user-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6" style="display:none">
|
||||
<label class="form-label" for="user_companyId_modal">公司</label>
|
||||
<input type="text" id="user_companyId_modal" name="user_companyId_modal" class="form-control" disabled>
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_name_modal"><span class="text-danger">*</span>姓名</label>
|
||||
<input type="text" id="user_name_modal" name="user_name_modal" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_email_modal"><span class="text-danger">*</span>email</label>
|
||||
<input type="text" id="user_email_modal" name="user_email_modal" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<div style="margin-bottom: 0.3rem">
|
||||
<label class="form-label" for="user_account_modal"><span class="text-danger">*</span>帳號</label>
|
||||
<input type="text" id="user_account_modal" name="user_account_modal" class="form-control">
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox user_account_same_email_div">
|
||||
<input type="checkbox" class="custom-control-input" id="user_account_same_email" />
|
||||
<label class="custom-control-label" for="user_account_same_email">與email相同</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6 user-password-div">
|
||||
<label class="form-label" for="user_password_modal">密碼</label>
|
||||
<input type="password" id="user_password_modal" name="user_password_modal" class="form-control" placeholder="由系統產生" disabled>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_role_modal">角色權限</label>
|
||||
<select class="form-control" id="user_role_modal">
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_phone_modal">電話</label>
|
||||
<input type="text" id="user_phone_modal" class="form-control">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<table id="company-power-station-table" class="table table-bordered text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>電站代碼</th>
|
||||
<th>電站名稱</th>
|
||||
<th>公司</th>
|
||||
<th>功能</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveUser()">確定</button>
|
||||
@*<button type="button" class="btn btn-primary" data-dismiss="modal">確定</button>*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.Modal 新增人員管理電站 -->
|
||||
Loading…
Reference in New Issue
Block a user