From 3275cfbaee1bb5a0368afa96c8f2db0e824cabb6 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 22 Sep 2021 14:22:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=B6=AD=E4=BF=AE=E5=96=AE=20--=20?= =?UTF-8?q?=E9=98=B2=E5=91=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/Operation/OperationRecord.cshtml | 184 ++++++++++-------- 1 file changed, 105 insertions(+), 79 deletions(-) diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index bde456f..bf4b398 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -148,15 +148,16 @@
- +
- + +
@@ -164,7 +165,7 @@
- +
@@ -179,9 +180,10 @@
- + +
@@ -291,6 +293,7 @@ $(function () { //#region Date-Picker + datepicker = $('#date-range').daterangepicker({ autoUpdateInput: false, locale: { format: 'YYYY/MM/DD' }, @@ -597,6 +600,20 @@ //#endregion }); + $('#work_person_select_modal').change(function () { + if ($('#work_person_select_modal').val().length == 0) { + $('#work_person_select_modal-error').show(); + } else { + $('#work_person_select_modal-error').hide(); + } + }); + + $('#work_time_modal').change(function () { + $("#work_time_modal-error").hide(); + }); + + + function getPowerStationCheckBox() { var send_data = { cityIds: ids @@ -684,8 +701,9 @@ $("#record-form").trigger("reset"); $("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態 $("#record_files_div > .row").empty(); - + $('#work_person_select_modal-error').hide(); + $("#work_time_modal-error").hide(); @@ -1026,7 +1044,7 @@ //#region 表單驗證 $("#record-form").validate({ rules: { - work_person_select_modal: { + work_time_modal: { required: true } }, @@ -1035,70 +1053,82 @@ //#region 儲存表單資料 function SaveRecord() { - Swal.fire( - { - title: "儲存", - text: "你確定是否儲存此筆資料?\r\n 儲存成功後將會發送Email至負責人員及廠商", - type: "warning", - icon: 'warning', - showCancelButton: true, - confirmButtonText: "是", - cancelButtonText: "否" - }).then(function (result) { - if (result.value) { - if ($("#record-form").valid()) { - var url = "/Operation/SaveOperationRecord"; + if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "") { + Swal.fire( + { + title: "儲存", + text: "你確定是否儲存此筆資料?\r\n 儲存成功後將會發送Email至負責人員及廠商", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + if ($("#record-form").valid()) { + var url = "/Operation/SaveOperationRecord"; - var formData = new FormData(); + var formData = new FormData(); - @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { - return parseInt(item); - }) *@ + @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { + return parseInt(item); + }) *@ - formData.append("Id", selected_id); - formData.append("PowerStationId", $("#power_station_select_modal").val()); - formData.append("WorkType", selected_work_type); - formData.append("ErrorCode", $("#error_code_modal").val()); - formData.append("FixDo", $("#fix_do_modal").val()); - formData.append("FixFirm", $("#fix_firm_select_modal").val()); - formData.append("Status", $("input[name=status_modal]:checked").val()); - $("#work_person_select_modal").val().forEach(function (item) { - formData.append("WorkPersonIds", parseInt(item)); - }); - formData.append("WorkTime", $("#work_time_modal").val()); - formData.append("Notice", $("#notice_textarea_modal").val()); - formData.append("Description", $("#description_textarea_modal").val()); + formData.append("Id", selected_id); + formData.append("PowerStationId", $("#power_station_select_modal").val()); + formData.append("WorkType", selected_work_type); + formData.append("ErrorCode", $("#error_code_modal").val()); + formData.append("FixDo", $("#fix_do_modal").val()); + formData.append("FixFirm", $("#fix_firm_select_modal").val()); + formData.append("Status", $("input[name=status_modal]:checked").val()); + $("#work_person_select_modal").val().forEach(function (item) { + formData.append("WorkPersonIds", parseInt(item)); + }); + formData.append("WorkTime", $("#work_time_modal").val()); + formData.append("Notice", $("#notice_textarea_modal").val()); + formData.append("Description", $("#description_textarea_modal").val()); - $.ajax({ - type: "POST", - url: url, - data: formData, - cache: false, - contentType: false, - processData: false, - success: function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } + $.ajax({ + type: "POST", + url: url, + data: formData, + cache: false, + contentType: false, + processData: false, + success: function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - var myDropzone = Dropzone.forElement("#record-file-form"); + var myDropzone = Dropzone.forElement("#record-file-form"); - if (myDropzone.files.length > 0) { + if (myDropzone.files.length > 0) { - selected_id = rel.data; + selected_id = rel.data; - myDropzone.processQueue(); + myDropzone.processQueue(); - myDropzone.on("successmultiple", function (file, rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - toast_ok(rel.msg); + toast_ok(rel.msg); + $('#record-form-modal').modal('hide'); + recordFileDropzone.removeAllFiles(); + if (status == 2) { + operationRecordTable.column(10).visible(true); + } + else { + operationRecordTable.column(10).visible(false); + } + operationRecordTable.ajax.reload(); + }); + } else { $('#record-form-modal').modal('hide'); - recordFileDropzone.removeAllFiles(); + myDropzone.removeAllFiles(); if (status == 2) { operationRecordTable.column(10).visible(true); } @@ -1106,29 +1136,25 @@ operationRecordTable.column(10).visible(false); } operationRecordTable.ajax.reload(); - }); - } else { - $('#record-form-modal').modal('hide'); - myDropzone.removeAllFiles(); - if (status == 2) { - operationRecordTable.column(10).visible(true); } - else { - operationRecordTable.column(10).visible(false); - } - operationRecordTable.ajax.reload(); } - } - }); + }); + } } - } - }); - - - - - - + }); + } + else + { + if ($('#work_person_select_modal').val().length == 0) + { + $('#work_person_select_modal-error').show(); + } + if ($("#work_time_modal").val() == "") + { + $("#work_time_modal-error").show(); + } + + } } //#endregion From d749cdabc88a274373c110f742f05a6266cf1934 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 22 Sep 2021 14:35:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20-=20=E4=BD=9C=E6=A5=AD?= =?UTF-8?q?=E7=B4=80=E9=8C=84=E5=BB=BA=E7=AB=8B=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/Operation.cs | 2 +- SolarPower/Quartz/Jobs/OperationScheduleJob.cs | 2 +- SolarPower/Repository/Implement/OperationRepository.cs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index fcbb6c9..f10b710 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -99,11 +99,11 @@ namespace SolarPower.Models public string UpdatedAt { get { return Convert.ToDateTime(updatedAt).ToString("yyyy-MM-dd HH:mm:ss"); } set { updatedAt = value; } } //修改時間 private string lastCreateTime; public string LastCreateTime { get { return Convert.ToDateTime(lastCreateTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { lastCreateTime = value; } } + public string PowerStationName { get; set; } } public class OperationPlanTable : OperationCreatePlan { public string TypeName { get; set; } - public string PowerStationName { get; set; } public string Schedule { get; set; } public string EmailTypeName { get; set; } public string CreatedPerson { get; set; } diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index c527148..cba78bf 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -158,7 +158,7 @@ namespace SolarPower.Quartz.Jobs { //Get所有運維人員 var personal = await operationRepository.GetOperationPersonnel(a.PowerStationId); - var Title = $@"編號:{a.PlanId} - {WorkType}單 - 作業紀錄建立通知"; + var Title = $@"電站:{a.PowerStationName} - {WorkType}單 - 編號:{a.PlanId}"; var content = $@" {noticeName} {Environment.NewLine} 內容描述:{a.Description}"; await operationRepository.InsertNoticeSchedule(personal, Title, content); diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index c752ecf..0e6435c 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -604,7 +604,8 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"SELECT * FROM operation_plan_create opc + var sql = @$"SELECT opc.*,ps.Name AS PowerStationName FROM operation_plan_create opc + LEFT JOIN power_station ps ON opc.PowerStationId = ps.Id WHERE opc.Deleted = 0"; result = (await conn.QueryAsync(sql)).ToList(); }