From 35f92baf93d12e0238f37be2692f215d55f6906c Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 22 Jun 2021 09:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9B=BB=E7=AB=99=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20=E4=B8=8A=E5=82=B3=E5=9C=96=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/CompanyController.cs | 12 +- SolarPower/Controllers/MyBaseController.cs | 2 +- .../Controllers/PowerStationController.cs | 558 +++++++++++++++++- SolarPower/Controllers/RoleController.cs | 8 +- SolarPower/DBSchema/solar_power_schema.sql | 3 +- SolarPower/Helper/DatabaseHelper.cs | 2 +- SolarPower/Models/ErrorCode.cs | 1 + SolarPower/Models/MyBaseModel.cs | 1 - SolarPower/Models/PowerStation.cs | 78 +++ SolarPower/Models/User.cs | 1 - .../Implement/PowerStationRepository.cs | 384 +++++++++++- .../Interface/IPowerStationRepository.cs | 95 +++ SolarPower/Views/Company/Index.cshtml | 4 +- .../PowerStation/PowerStationEdit.cshtml | 344 ++++++++++- .../Views/PowerStation/_StationInfo.cshtml | 145 +---- .../Views/PowerStation/_UploadImage.cshtml | 36 +- SolarPower/Views/Shared/_Layout.cshtml | 42 +- SolarPower/wwwroot/css/site.css | 6 + 18 files changed, 1506 insertions(+), 216 deletions(-) diff --git a/SolarPower/Controllers/CompanyController.cs b/SolarPower/Controllers/CompanyController.cs index e6f2b41..6e494d5 100644 --- a/SolarPower/Controllers/CompanyController.cs +++ b/SolarPower/Controllers/CompanyController.cs @@ -48,7 +48,7 @@ namespace SolarPower.Controllers { var companySelectItemLists = new List(); - if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer)) + if (!IsPlatformLayer(myUser.Role.Layer)) { companySelectItemLists = await companyRepository.GetCompanySelectOptionListAsync(myUser.CompanyId); } @@ -88,7 +88,7 @@ namespace SolarPower.Controllers try { - if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer)) + if (!IsPlatformLayer(myUser.Role.Layer)) { //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料 post.SelectedCompanyId = myUser.CompanyId; } @@ -112,8 +112,8 @@ namespace SolarPower.Controllers company.RegisterRatio = registerNumber.ToString() + " / " + company.RegisterUpperLimit.ToString(); - if (myUser.IsGod == 1 || IsPlatformLayer(myUser.Role.Layer)) - { //只有超級使用者 及 平台 可以使用 + if (IsPlatformLayer(myUser.Role.Layer)) + { //平台 可以使用 if(company.Id == 1) { //平台公司不能被刪 company.Function = @" @@ -183,7 +183,7 @@ namespace SolarPower.Controllers } else if (company.Id != myUser.CompanyId) { - if (myUser.IsGod != 0 && !IsPlatformLayer(myUser.Role.Layer)) + if (!IsPlatformLayer(myUser.Role.Layer)) { apiResult.Code = "9993"; apiResult.Msg = errorCode.GetString(apiResult.Code); @@ -273,7 +273,7 @@ namespace SolarPower.Controllers "CreatedBy", }; - if (myUser.IsGod == 1 || IsPlatformLayer(myUser.Role.Layer)) + if (IsPlatformLayer(myUser.Role.Layer)) { //超級使用者 或 平台人員可以修改 公司的註冊上限人數 properties.Add("RegisterUpperLimit"); } diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index f237307..b5719d2 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -66,7 +66,7 @@ namespace SolarPower.Controllers myUser.Role = roleRepository.GetMyRoleInfoById(myUser.RoleId); List auth_arr = new List(); - if (myUser.IsGod != 1 || myUser.Role.Layer != 0) //判斷是否神級使用者或平台管理員 + if (myUser.Role.Layer != 0) //判斷是否平台管理員 { foreach (var auth in myUser.Role.Auths) { diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index d504cb0..6ef4af8 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -20,6 +20,7 @@ namespace SolarPower.Controllers private readonly IUserRepository userRepository; private readonly IPowerStationRepository powerStationRepository; private string boeFilePath = "/upload/power_station/boe_file/"; + private string stationImageFilePath = "/upload/power_station/"; private string powerSationSaveAsPath = ""; public PowerStationController( @@ -309,6 +310,33 @@ namespace SolarPower.Controllers await powerStationRepository.AddOneLandBuildingInfo(landBuilding, landBuildingProperties); #endregion + #region 新增運維人員 + //找出要新增的 + if (post.OperationPersonnelIds != null) + { + List insertOperationPersonnels = new List(); + + foreach (var op in post.OperationPersonnelIds) + { + PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel(); + operationPersonnel.PowerStationId = id; + operationPersonnel.UserId = op; + operationPersonnel.CreatedBy = myUser.Id; + + insertOperationPersonnels.Add(operationPersonnel); + } + + List operationPersonnelProperties = new List() + { + "PowerStationId", + "UserId", + "CreatedBy", + }; + + await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, properties); + } + #endregion + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; apiResult.Data = await powerStationRepository.GetOneAsync(id); @@ -375,6 +403,59 @@ namespace SolarPower.Controllers await powerStationRepository.UpdatePowerStationInfo(update, properties); + List origOperationPersonnels = null; //原先的運維人員 + + origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id); + + //判斷新進來的資料是否要歸類到新增 or 刪除 + #region 刪除電站運維人員編號 + + //找出要刪除的 + List deleteOperationPersonnelIds = origOperationPersonnels.Where(x => !post.OperationPersonnelIds.Contains(x)).ToList(); + + List deleteOperationPersonnels = new List(); + foreach (var opId in deleteOperationPersonnelIds) + { + PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel(); + operationPersonnel.PowerStationId = powerStation.Id; + operationPersonnel.UserId = opId; + + deleteOperationPersonnels.Add(operationPersonnel); + } + + //刪除運維人員 + await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels); + #endregion + + #region 新增電站運維人員 + //找出要新增的 + if (post.OperationPersonnelIds != null) + { + List insertOperationPersonnelIds = post.OperationPersonnelIds.Where(x => !origOperationPersonnels.Contains(x)).ToList(); + + List insertOperationPersonnels = new List(); + + foreach (var op in insertOperationPersonnelIds) + { + PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel(); + operationPersonnel.PowerStationId = powerStation.Id; + operationPersonnel.UserId = op; + operationPersonnel.CreatedBy = myUser.Id; + + insertOperationPersonnels.Add(operationPersonnel); + } + + List operationPersonnelProperties = new List() + { + "PowerStationId", + "UserId", + "CreatedBy", + }; + + await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties); + } + #endregion + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id); @@ -701,7 +782,7 @@ namespace SolarPower.Controllers apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; } - + } catch (Exception exception) { @@ -718,23 +799,23 @@ namespace SolarPower.Controllers /// public async Task OperationTable(int stationId) { - + List operationTable = new List(); ApiResult> apiResult = new ApiResult>(); try { apiResult.Code = "0000"; operationTable = await powerStationRepository.OperationTable(stationId); - foreach(OperationTable a in operationTable) + foreach (OperationTable a in operationTable) { a.Function = @" "; if (a.Type == 0) { - a.TypeName = "施工"; + a.TypeName = "施工"; } - else if(a.Type == 1) + else if (a.Type == 1) { a.TypeName = "清洗"; } @@ -853,7 +934,7 @@ namespace SolarPower.Controllers Remark = Device.Remark, TableName = Device.TableName, Type = Device.Type, - UID = powerStation.Code + "-" + Device.Type + "-" + tempSerialNumber.ToString().PadLeft(3,'0'), + UID = powerStation.Code + "-" + Device.Type + "-" + tempSerialNumber.ToString().PadLeft(3, '0'), CreatedBy = myUser.Id, TypeName = Device.TypeName, SerialNumber = tempSerialNumber.ToString().PadLeft(3, '0') @@ -875,7 +956,7 @@ namespace SolarPower.Controllers "TypeName", "SerialNumber" }; - await powerStationRepository.AddDevice(DeviceInfo,properties); + await powerStationRepository.AddDevice(DeviceInfo, properties); apiResult.Code = "0000"; apiResult.Msg = "新增成功"; @@ -971,7 +1052,7 @@ namespace SolarPower.Controllers if (landBuilding == null) { - apiResult.Code = "9996"; + apiResult.Code = "9991"; apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; } @@ -1140,7 +1221,7 @@ namespace SolarPower.Controllers a.Function = @" "; - if(a.Type == 1) + if (a.Type == 1) { a.TypeName = "PR值"; } @@ -1185,6 +1266,7 @@ namespace SolarPower.Controllers return apiResult; } + /// /// 刪除一筆異常設定 /// @@ -1220,5 +1302,463 @@ namespace SolarPower.Controllers return apiResult; } + + + /// + /// 取得所有電站圖片 + /// + /// + /// + [HttpPost] + public async Task>> GetAllPowerStationImage(int powerStationId) + { + ApiResult> apiResult = new ApiResult>(); + + List powerStationImages = null; + + try + { + var powerStation = await powerStationRepository.GetOneAsync(powerStationId); + + if (powerStation == null) + { + apiResult.Code = "9992"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + else + { + powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStationId); + + foreach (var stationImage in powerStationImages) + { + stationImage.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + stationImage.Image; + } + } + + apiResult.Code = "0000"; + apiResult.Data = powerStationImages; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "PowerStationId=" + powerStationId); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + /// + /// 新增 電站圖片 + /// + /// + /// + [HttpPost] + public async Task>> SavePowerStationImages([FromForm] PostPowerStationImage post) + { + ApiResult> apiResult = new ApiResult>(); + + PowerStation powerStation = null; + + try + { + powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId); + + if (powerStation == null) + { + apiResult.Code = "9992"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + else + { + if (powerStation.CompanyId != myUser.CompanyId) + { + apiResult.Code = "9993"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + #region 新增圖片 + List powerStationImages; + + if (post.StationImages != null && post.StationImages.Length > 0) + { + FolderFunction folderFunction = new FolderFunction(); + + var imageSaveAsPath = Path.Combine(powerSationSaveAsPath, powerStation.Id.ToString()); + + folderFunction.CreateFolder(imageSaveAsPath, 0); + + powerStationImages = new List(); + + foreach (var image in post.StationImages) + { + var split = image.FileName.Split("."); + + var fileName = Guid.NewGuid() + "." + split[split.Length - 1]; + + var fullPath = Path.Combine(imageSaveAsPath, fileName); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + image.CopyTo(stream); + } + + PowerStationImage powerStationImage = new PowerStationImage() + { + PowerStationId = powerStation.Id, + Image = fileName, + CreatedBy = myUser.Id + }; + + powerStationImages.Add(powerStationImage); + } + + List properties = new List() + { + "PowerStationId", + "Image", + "CreatedBy" + }; + + await powerStationRepository.AddPowerStationImageAsync(powerStationImages, properties); + } + #endregion + + #region 重新取得圖片資訊 + powerStationImages = null; + powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStation.Id); + + foreach (var stationImage in powerStationImages) + { + stationImage.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + stationImage.Image; + } + #endregion + + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + apiResult.Data = powerStationImages; + } + } + 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> DeletePowerStationImage(int id) + { + ApiResult apiResult = new ApiResult(); + + PowerStationImage powerStationImage; + + try + { + powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(id); + + if (powerStationImage == null) + { + apiResult.Code = "9990"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + await powerStationRepository.DeleteOnePowerStationImage(id); + + 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; + } + + /// + /// 變更主要卡片顯示 + /// + /// + /// + public async Task> ChangeMainDisplay(PostChangeMainDisplay post) + { + ApiResult apiResult = new ApiResult(); + + PowerStationImage powerStationImage; + + try + { + powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(post.TargetImageId); + + if (powerStationImage == null) + { + apiResult.Code = "9990"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + UpdataPowerStationImage updata = new UpdataPowerStationImage(); + List properties = new List(); + + //找出原本的圖片 + var origMainDisplay = await powerStationRepository.GetMainDisplayAsync(post.PowerStationId); + if (origMainDisplay != null) + { + updata = new UpdataPowerStationImage() + { + Id=origMainDisplay.Id, + IsMainDisplay = 0, + UpdatedBy = myUser.Id + }; + + properties = new List() + { + "Id", + "IsMainDisplay", + "UpdatedBy" + }; + + await powerStationRepository.UpdatePowerStationImage(updata, properties); + } + + // 更新被選擇的圖維卡片顯示圖 + updata = new UpdataPowerStationImage() + { + Id = post.TargetImageId, + IsMainDisplay = 1, + UpdatedBy = myUser.Id + }; + + properties = new List() + { + "Id", + "IsMainDisplay", + "UpdatedBy" + }; + + await powerStationRepository.UpdatePowerStationImage(updata, properties); + + 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; + } + + + /// + /// 取得所有單線圖 + /// + /// + /// + [HttpPost] + public async Task>> GetAllPowerStationSingleLine(int powerStationId) + { + ApiResult> apiResult = new ApiResult>(); + + List powerStationSingleLines = null; + + try + { + var powerStation = await powerStationRepository.GetOneAsync(powerStationId); + + if (powerStation == null) + { + apiResult.Code = "9992"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + else + { + powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStationId); + + foreach (var singleLine in powerStationSingleLines) + { + singleLine.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + singleLine.Image; + } + } + + apiResult.Code = "0000"; + apiResult.Data = powerStationSingleLines; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "PowerStationId=" + powerStationId); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + /// + /// 新增 單線圖 + /// + /// + /// + [HttpPost] + public async Task>> SavePowerStationSingleLine([FromForm] PostPowerStationSingleLine post) + { + ApiResult> apiResult = new ApiResult>(); + + PowerStation powerStation = null; + + try + { + powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId); + + if (powerStation == null) + { + apiResult.Code = "9992"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + else + { + if (powerStation.CompanyId != myUser.CompanyId) + { + apiResult.Code = "9993"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + #region 新增圖片 + List powerStationSingleLines; + + if (post.SingleLineImages != null && post.SingleLineImages.Length > 0) + { + FolderFunction folderFunction = new FolderFunction(); + + var imageSaveAsPath = Path.Combine(powerSationSaveAsPath, powerStation.Id.ToString()); + + folderFunction.CreateFolder(imageSaveAsPath, 0); + + powerStationSingleLines = new List(); + + foreach (var image in post.SingleLineImages) + { + var split = image.FileName.Split("."); + + var fileName = Guid.NewGuid() + "." + split[split.Length - 1]; + + var fullPath = Path.Combine(imageSaveAsPath, fileName); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + image.CopyTo(stream); + } + + PowerStationSingleLine powerStationSingleLine = new PowerStationSingleLine() + { + PowerStationId = powerStation.Id, + Image = fileName, + CreatedBy = myUser.Id + }; + + powerStationSingleLines.Add(powerStationSingleLine); + } + + List properties = new List() + { + "PowerStationId", + "Image", + "CreatedBy" + }; + + await powerStationRepository.AddPowerStationSingleLineAsync(powerStationSingleLines, properties); + } + #endregion + + #region 重新取得圖片資訊 + powerStationSingleLines = null; + powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStation.Id); + + foreach (var singleLine in powerStationSingleLines) + { + singleLine.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + singleLine.Image; + } + #endregion + + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + apiResult.Data = powerStationSingleLines; + } + } + 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> DeletePowerStationSingleLine(int id) + { + ApiResult apiResult = new ApiResult(); + + PowerStationSingleLine powerStationSingleLine; + + try + { + powerStationSingleLine = await powerStationRepository.GetOnePowerStationSingleLineAsync(id); + + if (powerStationSingleLine == null) + { + apiResult.Code = "9990"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + await powerStationRepository.DeleteOnePowerStationSingleLine(id); + + 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; + } } } diff --git a/SolarPower/Controllers/RoleController.cs b/SolarPower/Controllers/RoleController.cs index 471e630..6902af0 100644 --- a/SolarPower/Controllers/RoleController.cs +++ b/SolarPower/Controllers/RoleController.cs @@ -170,8 +170,8 @@ namespace SolarPower.Controllers } - if(myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) - { //非超級使用者或平台人員,就只能新增自己公司的角色 + if(!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) + { //非平台人員,就只能新增自己公司的角色 apiResult.Code = "9993"; apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; @@ -212,8 +212,8 @@ namespace SolarPower.Controllers { #region 修改公司角色 - if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) - { //非超級使用者或平台人員,就只能修改自己公司的角色 + if (!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) + { //非平台人員,就只能修改自己公司的角色 apiResult.Code = "9993"; apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index 8c950e2..1d4cc01 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -819,7 +819,8 @@ INSERT INTO `variable` (`id`, `name`, `value`, `remark`) VALUES /****************************** ** 後續SQL修改從以下開始新增 ** *******************************/ -ALTER TABLE `device` ADD COLUMN `SerialNumber` VARCHAR(3) NULL DEFAULT NULL COMMENT '單一設備流水號' COLLATE 'utf8mb4_unicode_ci' AFTER `PowerStationId`;/* 設備流水號 - 2021/6/18 12:21:00 */ +-- 設備流水號 - 2021/6/18 12:21:00 +ALTER TABLE `device` ADD COLUMN `SerialNumber` VARCHAR(3) NULL DEFAULT NULL COMMENT '單一設備流水號' COLLATE 'utf8mb4_unicode_ci' AFTER `PowerStationId`; diff --git a/SolarPower/Helper/DatabaseHelper.cs b/SolarPower/Helper/DatabaseHelper.cs index 2e57aa3..b359893 100644 --- a/SolarPower/Helper/DatabaseHelper.cs +++ b/SolarPower/Helper/DatabaseHelper.cs @@ -37,7 +37,7 @@ namespace SolarPower.Helper var passwordStr = ed.DESDecrypt(dbConfig.Password); //var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;"; - var connStr = @"server=127.0.0.1;port=3308;database=solar_power;user=root;password=00000000;charset=utf8;"; + var connStr = @"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;"; this._connectionString = connStr; } diff --git a/SolarPower/Models/ErrorCode.cs b/SolarPower/Models/ErrorCode.cs index 4744706..a3d77ca 100644 --- a/SolarPower/Models/ErrorCode.cs +++ b/SolarPower/Models/ErrorCode.cs @@ -17,6 +17,7 @@ namespace SolarPower.Models { { "0000", "OK" }, { "0001", "傳入參數錯誤。" }, + { "9990", "查無該圖片"}, { "9991", "查無該土地房屋資訊"}, { "9992", "查無該電站資訊"}, { "9993", "無此權限操作"}, diff --git a/SolarPower/Models/MyBaseModel.cs b/SolarPower/Models/MyBaseModel.cs index 7ac2dbd..5fde68a 100644 --- a/SolarPower/Models/MyBaseModel.cs +++ b/SolarPower/Models/MyBaseModel.cs @@ -36,7 +36,6 @@ namespace SolarPower.Models public int Id { get; set; } //編號 public byte Status { get; set; } //狀態 public string Name { get; set; } //姓名 - public byte IsGod { get; set; } //神級使用者 public int CompanyId { get; set; } //公司編號 public int RoleId { get; set; } //角色編號 public string Email { get; set; } diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 96b733a..054182d 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -38,6 +38,7 @@ namespace SolarPower.Models.PowerStation public int EstimatedRecoveryTime { get; set; } //預計回收年限 public double GeneratingCapacity { get; set; } //發電容量 public double PowerRate { get; set; } //授電費率 + public List OperationPersonnelIds { get; set; } //運維人員編號 public string Coordinate { get; set; } //座標 public string InverterBrand { get; set; } //逆變器廠牌 public string InverterProductModel { get; set; } //逆變器型號 @@ -134,6 +135,12 @@ namespace SolarPower.Models.PowerStation } + public class PowerStationOperationPersonnel : Created + { + public int PowerStationId { get; set; } + public int UserId { get; set; } + } + public class PostPowerStationInfo { public int Id { get; set; } @@ -149,6 +156,7 @@ namespace SolarPower.Models.PowerStation public double GeneratingCapacity { get; set; } //發電容量 public double PowerRate { get; set; } //授電費率 public string Coordinate { get; set; } //座標 + public List OperationPersonnelIds { get; set; } //運維人員編號 public string InverterBrand { get; set; } //逆變器廠牌 public string InverterProductModel { get; set; } //逆變器型號 public int InverterAmount { get; set; } //逆變器數量 @@ -279,16 +287,19 @@ namespace SolarPower.Models.PowerStation public string Phone { get; set; }//電話 public string Email { get; set; }//Email } + public class OperationStationId { public int stationId { get; set; } } + public class OperationTable : OperationInfo { public string CreatedName { get; set; }//建立者名稱 public string Function { get; set; }//功能 public string TypeName { get; set; } } + /// /// 設備裝置下拉選單 /// @@ -297,10 +308,12 @@ namespace SolarPower.Models.PowerStation public string Name { get; set; } public string EName { get; set; } } + public class Root { public List Type { get; set; } } + /// /// 表Variable 取來解析 /// @@ -309,6 +322,7 @@ namespace SolarPower.Models.PowerStation public string name { get; set; } public string value { get; set; } } + /// /// 設備 /// @@ -326,12 +340,14 @@ namespace SolarPower.Models.PowerStation public string Remark { get; set; } public string TypeName { get; set; }//類型名稱 } + public class Device : DeviceInfo { public string UID { get; set; }//設備編號 public int CreatedBy { get; set; }//建立者 public string SerialNumber { get; set; } } + /// ///設備dataTable /// @@ -340,6 +356,7 @@ namespace SolarPower.Models.PowerStation public string UID { get; set; }//設備編號 public string Function { get; set; }//功能 } + /// /// 異常modal /// @@ -352,6 +369,7 @@ namespace SolarPower.Models.PowerStation public decimal LowerLimit { get; set; } public byte Alarm { get; set; } } + /// /// 異常設定Table /// @@ -364,4 +382,64 @@ namespace SolarPower.Models.PowerStation public string AlarmName { get; set; } } + /// + /// 上傳電站圖片 + /// + public class PostPowerStationImage + { + public int Id { get; set; } + public int PowerStationId { get; set; } + public IFormFile[] StationImages { get; set; } + } + + /// + /// 電站圖片資訊 + /// + public class PowerStationImage : Created + { + public int Id { get; set; } + public int PowerStationId { get; set; } + public byte IsMainDisplay { get; set; } + public string Image { get; set; } + } + + /// + /// 上傳卡片顯示圖 + /// + public class PostChangeMainDisplay + { + public int PowerStationId { get; set; } + public int TargetImageId { get; set; } + } + + /// + /// 更新電站圖片 + /// + public class UpdataPowerStationImage: Updated + { + public int PowerStationId { get; set; } + public byte IsMainDisplay { get; set; } + public string Image { get; set; } + } + + /// + /// 上傳單線圖 + /// + public class PostPowerStationSingleLine + { + public int Id { get; set; } + public int PowerStationId { get; set; } + public IFormFile[] SingleLineImages { get; set; } + } + + /// + /// 單線圖片資訊 + /// + public class PowerStationSingleLine : Created + { + public int Id { get; set; } + public int PowerStationId { get; set; } + public string Image { get; set; } + } + } diff --git a/SolarPower/Models/User.cs b/SolarPower/Models/User.cs index c380ccd..d3a0b3a 100644 --- a/SolarPower/Models/User.cs +++ b/SolarPower/Models/User.cs @@ -59,7 +59,6 @@ namespace SolarPower.Models.User public string Name { get; set; } //姓名 public string Account { get; set; } //帳號 public byte Status { get; set; } //狀態 - public byte IsGod { get; set; } //神級帳號 public int CompanyId { get; set; } //公司編號 public string Email { get; set; } //信箱 public string Phone { get; set; } //手機 diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 1f9c4b4..fb0c6d3 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -44,7 +44,7 @@ namespace SolarPower.Repository.Implement } /// - /// 查詢縣市列表 + /// 查詢地區列表 /// /// /// @@ -55,7 +55,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = $"SELECT Id AS Value, Name AS Text FROM Area WHERE CityId = @CityId"; + var sql = $"SELECT Id AS Value, Name AS Text FROM area WHERE CityId = @CityId"; result = (await conn.QueryAsync(sql, new { CityId = cityId })).ToList(); } @@ -167,7 +167,6 @@ namespace SolarPower.Repository.Implement } } - /// /// 透過電站編號,取得單一電站資訊(覆寫) /// @@ -191,6 +190,9 @@ namespace SolarPower.Repository.Implement if(result!= null) { + var sql_operation_personnel = @"SELECT UserId FROM power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId"; + result.OperationPersonnelIds = (await conn.QueryAsync(sql_operation_personnel, new { PowerStationId = result.Id })).ToList(); + var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM land_building lb LEFT JOIN user u ON lb.CreatedBy = u.Id WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId"; @@ -809,5 +811,381 @@ namespace SolarPower.Repository.Implement } return Num; } + + /// + /// 透過電站編號,取得該電站的運維人員編號 + /// + /// + /// + public async Task> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + try + { + var sql = @$"SELECT UserId FROM power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId"; + + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + return result; + } + } + + /// + /// 新增電站運維人員 + /// + /// + /// + /// + public async Task AddOperationPersonnelAsync(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_operation_personnel"); + + count = await conn.ExecuteAsync(sql, entity); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + + return count; + } + } + + /// + /// 軟刪除電站運維人員 + /// + /// + /// + public async Task DeleteOperationPersonnel(List operationPersonnels) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = $"UPDATE power_station_operation_personnel SET deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId"; + + await conn.ExecuteAsync(sql, operationPersonnels, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 電站管理 新增電站圖片 + /// + /// + /// + /// + public async Task AddPowerStationImageAsync(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_image"); + + count = await conn.ExecuteAsync(sql, entity); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + + return count; + } + } + + /// + /// 電站管理 取得所有電站圖片的資料 + /// + /// + /// + public async Task> GetAllPowerStationImageAsync(int powerStationId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND PowerStationId = @PowerStationId"; + + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 電站管理 取得單一電站圖片的資料 + /// + /// + /// + public async Task GetOnePowerStationImageAsync(int id) + { + PowerStationImage result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND Id = @Id"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { Id = id }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 軟刪除 單一電站圖片 + /// + /// + /// + public async Task DeleteOnePowerStationImage(int id) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = $"UPDATE power_station_image SET deleted = 1 WHERE id = @Id"; + + await conn.ExecuteAsync(sql, new { Id = id }, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 電站管理 取得主要卡片顯示圖 + /// + /// + /// + public async Task GetMainDisplayAsync(int powerStationId) + { + PowerStationImage result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND IsMainDisplay = 1 AND PowerStationId = @PowerStationId"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { PowerStationId = powerStationId }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 電站管理 更新上傳圖片 + /// + /// + /// + /// + public async Task UpdatePowerStationImage(UpdataPowerStationImage image, List properties) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = GenerateUpdateQueryWithCustomTable(properties, "power_station_image"); + + await conn.ExecuteAsync(sql, image, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 電站管理 新增單線圖 + /// + /// + /// + /// + public async Task AddPowerStationSingleLineAsync(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_single_line_diagram"); + + count = await conn.ExecuteAsync(sql, entity); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + + return count; + } + } + + /// + /// 電站管理 取得所有單線圖的資料 + /// + /// + /// + public async Task> GetAllPowerStationSingleLineAsync(int powerStationId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND PowerStationId = @PowerStationId"; + + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 電站管理 取得單一單線圖的資料 + /// + /// + /// + public async Task GetOnePowerStationSingleLineAsync(int id) + { + PowerStationSingleLine result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND Id = @Id"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { Id = id }); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + + /// + /// 軟刪除 單一單線圖 + /// + /// + /// + public async Task DeleteOnePowerStationSingleLine(int id) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = $"UPDATE power_station_single_line_diagram SET deleted = 1 WHERE id = @Id"; + + await conn.ExecuteAsync(sql, new { Id = id }, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + } } diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index bd3e555..73c0ddc 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -188,5 +188,100 @@ namespace SolarPower.Repository.Interface /// /// Task GetFinalSerialNumber(int PowerStationId, string Type); + + /// + /// 透過電站編號,取得該電站的運維人員編號 + /// + /// + /// + Task> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId); + + /// + /// 新增電站運維人員 + /// + /// + /// + /// + Task AddOperationPersonnelAsync(List entity, List properties); + + /// + /// 軟刪除電站運維人員 + /// + /// + /// + Task DeleteOperationPersonnel(List operationPersonnels); + + /// + /// 電站管理 新增電站圖片 + /// + /// + /// + /// + Task AddPowerStationImageAsync(List entity, List properties); + + /// + /// 電站管理 取得所有電站圖片的資料 + /// + /// + /// + Task> GetAllPowerStationImageAsync(int powerStationId); + + /// + /// 電站管理 取得單一電站圖片的資料 + /// + /// + /// + Task GetOnePowerStationImageAsync(int id); + + /// + /// 軟刪除 單一電站圖片 + /// + /// + /// + Task DeleteOnePowerStationImage(int id); + + /// + /// 電站管理 取得主要卡片顯示圖 + /// + /// + /// + Task GetMainDisplayAsync(int powerStationId); + + /// + /// 電站管理 更新上傳圖片 + /// + /// + /// + /// + Task UpdatePowerStationImage(UpdataPowerStationImage image, List properties); + + /// + /// 電站管理 新增單線圖 + /// + /// + /// + /// + Task AddPowerStationSingleLineAsync(List entity, List properties); + + /// + /// 電站管理 取得所有單線圖的資料 + /// + /// + /// + Task> GetAllPowerStationSingleLineAsync(int powerStationId); + + /// + /// 電站管理 取得單一單線圖的資料 + /// + /// + /// + Task GetOnePowerStationSingleLineAsync(int id); + + /// + /// 軟刪除 單一單線圖 + /// + /// + /// + Task DeleteOnePowerStationSingleLine(int id); } } diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index 1a7fdb0..a97f286 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -54,8 +54,8 @@
- @*只有超級使用者及平台人員可以新增公司*@ - @if (ViewBag.myUser.IsGod == 1 || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) + @*只有平台人員可以新增公司*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) { ' + '' + - '' + '' + '
' + '
'; @@ -1147,15 +1207,15 @@ '
' + '
土地房屋資料
' + '
' + - '' + '
' + - '' + - '' + '
' + '
' + @@ -1298,7 +1358,6 @@ //取消 $('#land_buildingPart').on("click", "#add-land-building-card button#cancel-add-land-building-info-btn", function () { - alert("bbb"); $("#add-land-building-card > .card-body").collapse('hide'); $("#add-land-building-card button#add-land-building-info-btn").show(); @@ -1518,7 +1577,7 @@ $("#Exception-modal").modal(); } //#endregion - + //#region 儲存異常設定資料 function SaveException() { @@ -1603,5 +1662,256 @@ }); //#endregion + + //#region 上傳資料 tab + + Dropzone.autoDiscover = false; + + //#region 電站圖片 Dropzone + var powerStationImagsDropzone = new Dropzone("#power-station-images-form", { + url: "/PowerStation/SavePowerStationImages", + paramName: "StationImage", + acceptedFiles: "image/*", + autoProcessQueue: false, + parallelUploads: 5, + maxFiles: 5, + addRemoveLinks: true, + uploadMultiple: true, + dictRemoveFile: "移除", + init: function (e) { + + var myDropzone = this; + $("#upload-station-image").click(function (e) { + myDropzone.processQueue(); + }); + + myDropzone.on("sending", function (file, xhr, data) { + if ((countPowerStationImage + myDropzone.files.length) > 5) { + toast_warning("圖片總數量不可超過 5 張"); + myDropzone.removeFile(file); + return; + } else { + data.append("PowerStationId", stationId); + data.append("StationImages", file); + } + }); + + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code == "9999") { + toast_error(rel.msg); + return; + } + + toast_ok(rel.msg); + countPowerStationImage = rel.data.length; + powerStationImagsDropzone.removeAllFiles(); + + powerStationImageCard = $("#power-station-image-card > .row"); + powerStationImageCard.empty(); + rel.data.forEach(function (value, index) { + CreatePowerStationImageBox(powerStationImageCard, value); + }); + + }); + } + }); + //#endregion + + //#region 創建電站圖片box + function CreatePowerStationImageBox(dom, value) { + var str = '
' + + '
' + + '...' + + '' + + '' + + '' + + '
' + + '
'; + if (value.isMainDisplay == 1) { + str += ''; + } + else { + str += ''; + } + str += '' + + '
' + + '
' + + '
' + + '
'; + + dom.append(str); + } + //#endregion + + //#region 刪除電站圖片 + $('#power-station-image-card').on("click", "a.del-power-station-image-btn", function () { + + var selectedImageId = $(this).attr("data-id"); + + var div = $(this).parents(".col-xl"); + + Swal.fire({ + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + + var url = "/PowerStation/DeletePowerStationImage"; + + var send_data = { + Id: selectedImageId + } + + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + + toast_ok(rel.msg); + countPowerStationImage -= 1; + div.remove(); + }, 'json'); + } + }); + }); + //#endregion + + //#region 卡片顯示圖 + $("#power-station-image-card").on("click", ".ckeck-main-display", function () { + + if (!this.checked) { + return + } + + var selectedImageId = $(this).attr("data-id"); + + var url = "/PowerStation/ChangeMainDisplay"; + + var send_data = { + PowerStationId: stationId, + TargetImageId: selectedImageId + } + + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + + toast_ok(rel.msg); + }, 'json'); + }); + //#endregion + + //#region 單線圖 Dropzone + var powerStationSingleLineDropzone = new Dropzone("#power-station-single-line-form", { + url: "/PowerStation/SavePowerStationSingleLine", + acceptedFiles: "image/*", + autoProcessQueue: false, + parallelUploads: 1, + maxFiles: 1, + addRemoveLinks: true, + uploadMultiple: true, + dictRemoveFile: "移除", + init: function (e) { + + var myDropzone = this; + $("#upload-station-single-line").click(function (e) { + myDropzone.processQueue(); + }); + + myDropzone.on("sending", function (file, xhr, data) { + if ((countPowerStationSingleLine + myDropzone.files.length) > 1) { + toast_warning("請先刪除原本圖片"); + myDropzone.removeFile(file); + return; + } else { + data.append("PowerStationId", stationId); + data.append("SingleLineImages", file); + } + }); + + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code == "9999") { + toast_error(rel.msg); + return; + } + + toast_ok(rel.msg); + countPowerStationSingleLine = rel.data.length; + powerStationSingleLineDropzone.removeAllFiles(); + + powerStationSingleLineCard = $("#power-station-single-line-card > .row"); + powerStationSingleLineCard.empty(); + rel.data.forEach(function (value, index) { + CreatePowerStationSingleLineBox(powerStationSingleLineCard, value); + }); + + }); + } + }); + //#endregion + + //#region 創建單線圖box + function CreatePowerStationSingleLineBox(dom, value) { + var str = '
' + + '
' + + '...' + + '' + + '' + + '' + + '
' + + '
'; + + dom.append(str); + } + //#endregion + + //#region 刪除單線圖 + $('#power-station-single-line-card').on("click", "a.del-power-station-single-line-btn", function () { + + var selectedImageId = $(this).attr("data-id"); + + var div = $(this).parents(".col-xl"); + + Swal.fire({ + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + + var url = "/PowerStation/DeletePowerStationSingleLine"; + + var send_data = { + Id: selectedImageId + } + + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + + toast_ok(rel.msg); + countPowerStationSingleLine -= 1; + div.remove(); + }, 'json'); + } + }); + }); + //#endregion + + //#endregion } \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml index 0949d0d..84d91c5 100644 --- a/SolarPower/Views/PowerStation/_StationInfo.cshtml +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -5,14 +5,14 @@
電站基本資料
@@ -209,14 +209,14 @@
經濟部能源局與台電資訊
@@ -319,133 +319,4 @@
- - - - - - -
diff --git a/SolarPower/Views/PowerStation/_UploadImage.cshtml b/SolarPower/Views/PowerStation/_UploadImage.cshtml index 347e177..6163973 100644 --- a/SolarPower/Views/PowerStation/_UploadImage.cshtml +++ b/SolarPower/Views/PowerStation/_UploadImage.cshtml @@ -5,14 +5,14 @@
圖片上傳
-
-
+ +
+ +

- Drop files here or click to upload. + 將圖片拖曳至這裡或點擊選擇圖片.
- This is just a demo dropzone. Selected files are not actually uploaded. + 僅供預覽,並未實際上傳。
@@ -90,20 +93,20 @@
- *@ @@ -1131,13 +1135,15 @@ + + @**@ + + - - - + @*各頁面的JavaScript*@ @RenderSection("Scripts", required: false) diff --git a/SolarPower/wwwroot/css/site.css b/SolarPower/wwwroot/css/site.css index 806f9bd..5882a5e 100644 --- a/SolarPower/wwwroot/css/site.css +++ b/SolarPower/wwwroot/css/site.css @@ -15,4 +15,10 @@ html { /* JQuery Validate*/ label.error { color: red; +} + +/* 隱藏圖片上傳 progress bar */ + +#power-station-images-form .dz-preview .dz-progress, #power-station-single-line-form .dz-preview .dz-progress { + display: none; } \ No newline at end of file