修改即時->今日 新增Email通知勾選

This commit is contained in:
b110212000 2021-10-13 16:34:50 +08:00
parent 781bf9e660
commit e426559bde
7 changed files with 344 additions and 252 deletions

View File

@ -659,6 +659,8 @@ namespace SolarPower.Controllers
}
if(post.Emailcheck == 1)
{
if (post.WorkPersonIds != null)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
@ -733,8 +735,7 @@ namespace SolarPower.Controllers
};
await noticeScheduleRepository.AddAnyThing<NoticeSchedule>(schedule, properties, "notice_schedule");
}
}
//using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Suppress))
//{
@ -880,7 +881,8 @@ namespace SolarPower.Controllers
}
#endregion
if (post.Emailcheck == 1)
{
if (post.WorkPersonIds != null)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
@ -957,6 +959,11 @@ namespace SolarPower.Controllers
}
}
#endregion

View File

@ -293,6 +293,7 @@ namespace SolarPower.Models
public string Notice { get; set; }
public string Description { get; set; }
public IFormFile[] RecordFiles { get; set; }
public byte Emailcheck { get; set; }
}
public class UpdateOperationRecord : Updated

View File

@ -20,7 +20,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時總發電量</p>
<p>今日總發電量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwh">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -36,7 +36,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時日照度</p>
<p>今日日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -279,7 +279,7 @@
'<div class="row">' +
'<div class="col-12">' +
'<div>今日發電量(kW h)' + item.today_kWh.toFixed(2) + '</div>'+
'<div>即時日照度(k W/m<sup>2</sup>)' + item.today_irradiance + '</div>'+
'<div>今日日照度(k W/m<sup>2</sup>)' + item.today_irradiance + '</div>'+
'<div>有效日照時數(kwh/kwp)' + item.today_kwhkwp.toFixed(2) + '</div>' +
'<div>裝置容量(kWp)' + item.generatingCapacity.toFixed(3) + '</div>' +
'<div>掛錶日期:' + item.electricityMeterAt + '</div>' +

View File

@ -211,8 +211,13 @@
<select class="form-control" id="fix_firm_select_modal"></select>
</div>
</div>
<div class="col-lg-6 mt-5">
<div class="custom-control custom-checkbox d-flex align-content-center">
<input type="checkbox" class="custom-control-input" id="EmailcheckBox">
<label class="custom-control-label" for="EmailcheckBox">發送Email通知</label>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-12">
<div class="form-group">
@ -707,7 +712,7 @@
$("#work_time_modal-error").hide();
$("#EmailcheckBox").prop("checked", false);
$("#record-form-modal").modal();
}
//#endregion
@ -1038,7 +1043,7 @@
$("#EmailcheckBox").prop("checked", false);
$("#record-form-modal").modal();
}, 'json');
});
@ -1057,18 +1062,8 @@
//#region 儲存表單資料
function SaveRecord() {
if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "") {
Swal.fire(
if ($("#record-form").valid())
{
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();
@ -1090,7 +1085,12 @@
formData.append("WorkTime", $("#work_time_modal").val());
formData.append("Notice", $("#notice_textarea_modal").val());
formData.append("Description", $("#description_textarea_modal").val());
if (document.querySelector('[id=EmailcheckBox]:checked')) {
formData.append("Emailcheck", 1);
}
else {
formData.append("Emailcheck", 0);
}
$.ajax({
type: "POST",
url: url,
@ -1144,8 +1144,6 @@
});
}
}
});
}
else
{
if ($('#work_person_select_modal').val().length == 0)

View File

@ -94,7 +94,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時日照度</p>
<p>今日日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">

View File

@ -951,6 +951,32 @@
$("#work_person_select_modal").val(record.workPersonId);
}
}
$("#work_person_select_modal").select2({ dropdownParent: $('#record-form-modal') });
});
//查詢該電站的廠商
var url_power_station_firm = "/PowerStation/GetFirmSelectOptionList";
$.post(url_power_station_firm, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#fix_firm_select_modal").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#fix_firm_select_modal").append($("<option />").val(val.value).text(val.text));
});
}
$("#fix_firm_select_modal").val($("#fix_firm_select_modal option:first").val()).trigger('change');
if (record != undefined && record != null) {
$("#fix_firm_select_modal").val(record.fixFirm)
}
});
});
//#endregion
@ -1510,7 +1536,7 @@
status = 1;
}
$("input[name=status_modal_opRecord][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal').val(record.workPersonId);
$('#work_person_select_modal').val(record.workPersonId).trigger("change");;
if (work_type != 2) {
$(".fix-div").hide();
} else {
@ -1518,6 +1544,7 @@
$("#error_code_modal").val(record.errorCode);
$("#fix_do_modal").val(record.fixDo);
}
$("#fix_firm_select_modal").val(record.fixFirm).trigger("change");
$("#notice_textarea_modal").val(record.notice);
$("#description_textarea_modal").val(record.description);
@ -1528,12 +1555,22 @@
record.recordFiles.forEach(function (value, index) {
CreateRecordFileBox(RecordFileBox, value, true);
});
$("#EmailcheckBox").prop("checked", false);
$("#record-form-modal").modal();
}, 'json');
});
//#endregion
//#region 表單驗證
$("#record-form").validate({
rules: {
work_time_modal: {
required: true
}
},
});
//#endregion
//#region 表單檔案資料(運維)
Dropzone.autoDiscover = false;
recordFileDropzone = new Dropzone("#record-file-form", {
@ -1582,9 +1619,22 @@
}
//#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();
});
//#region 儲存表單資料(運維)
function SaveRecord() {
if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "")
{
if ($("#record-form").valid()) {
var url = "/Operation/SaveOperationRecord";
@ -1595,12 +1645,20 @@
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_opRecord]:checked").val());
formData.append("WorkPersonId", $("#work_person_select_modal").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());
if (document.querySelector('[id=EmailcheckBox]:checked')) {
formData.append("Emailcheck", 1);
}
else {
formData.append("Emailcheck", 0);
}
$.ajax({
type: "POST",
url: url,
@ -1642,6 +1700,16 @@
});
}
}
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
//#region 點擊圖片放大(運維)

View File

@ -79,7 +79,7 @@
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="power_station_select_modal">電站</label>
<label class="form-label" for="power_station_select_modal"><span class="text-danger">*</span>電站</label>
@*<input class="form-control" id="power_station_select_modal" type="text" name="power_station_select_modal" />*@
<select class="form-control" id="power_station_select_modal">
</select>
@ -87,8 +87,9 @@
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="work_time_modal">作業日期</label>
<label class="form-label" for="work_time_modal"><span class="text-danger">*</span>作業日期</label>
<input class="form-control" id="work_time_modal" type="date" name="work_time_modal" />
<label id="work_time_modal-error" class="" style="z-index:1;color:red;display:none">此為必填欄位</label>
</div>
</div>
</div>
@ -96,7 +97,7 @@
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="example-select">狀態</label>
<label class="form-label" for="example-select"><span class="text-danger">*</span>狀態</label>
<div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input ml-auto" id="status_none_complete" name="status_modal_opRecord" value="0" />
@ -111,11 +112,13 @@
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="work_person_select_modal">執行人員</label>
<select class="form-control" id="work_person_select_modal">
<label class="form-label" for="work_person_select_modal"><span class="text-danger">*</span>執行人員</label>
<select class="form-control" id="work_person_select_modal" multiple="multiple">
</select>
<label id="work_person_select_modal-error" class="" style="z-index:1;color:red;display:none">此為必填欄位</label>
</div>
</div>
</div>
<div class="row mb-3 fix-div">
@ -123,7 +126,7 @@
<div class="form-group">
<div class="form-group">
<label class="form-label" for="error_code_modal">異常編號</label>
<input class="form-control" id="error_code_modal" type="text" name="error_code_modal" />
<input class="form-control" id="error_code_modal" type="text" name="error_code_modal" disabled/>
</div>
</div>
</div>
@ -135,10 +138,25 @@
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="fix_firm_modal">負責廠商</label>
<select class="form-control" id="fix_firm_select_modal"></select>
</div>
</div>
<div class="col-lg-6 mt-5">
<div class="custom-control custom-checkbox d-flex align-content-center">
<input type="checkbox" class="custom-control-input" id="EmailcheckBox">
<label class="custom-control-label" for="EmailcheckBox">發送Email通知</label>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="notice_textarea_modal">巡檢注意事項</label>
<label class="form-label" for="notice_textarea_modal">項目內容</label>
<textarea class="form-control" id="notice_textarea_modal" rows="5"></textarea>
</div>
</div>