Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
4d7e31953a
@ -1,6 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SolarPower.Models;
|
using SolarPower.Models;
|
||||||
|
using SolarPower.Models.PowerStation;
|
||||||
using SolarPower.Models.Role;
|
using SolarPower.Models.Role;
|
||||||
using SolarPower.Repository.Interface;
|
using SolarPower.Repository.Interface;
|
||||||
using System;
|
using System;
|
||||||
@ -15,16 +18,22 @@ namespace SolarPower.Controllers
|
|||||||
public class OperationController : MyBaseController<OperationController>
|
public class OperationController : MyBaseController<OperationController>
|
||||||
{
|
{
|
||||||
private readonly IOperationRepository operationRepository;
|
private readonly IOperationRepository operationRepository;
|
||||||
private string operationRecordFilePath = "/upload/operation_record/";
|
private readonly IPowerStationRepository powerStationRepository;
|
||||||
|
private readonly IUserRepository userRepository;
|
||||||
|
private readonly INoticeScheduleRepository noticeScheduleRepository;
|
||||||
|
private string operationRecordFilePath = "/upload/operation_recode/";
|
||||||
private string operationRecordSaveAsPath = "";
|
private string operationRecordSaveAsPath = "";
|
||||||
|
public IWebHostEnvironment environment;
|
||||||
|
|
||||||
public OperationController(
|
public OperationController(
|
||||||
IOperationRepository operationRepository) : base()
|
IOperationRepository operationRepository, IWebHostEnvironment environment,IPowerStationRepository powerStationRepository,IUserRepository userRepository,INoticeScheduleRepository noticeScheduleRepository) : base()
|
||||||
{
|
{
|
||||||
|
this.noticeScheduleRepository = noticeScheduleRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
this.powerStationRepository = powerStationRepository;
|
||||||
this.operationRepository = operationRepository;
|
this.operationRepository = operationRepository;
|
||||||
|
this.environment = environment;
|
||||||
operationRecordSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_record");
|
operationRecordSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_recode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -534,27 +543,25 @@ namespace SolarPower.Controllers
|
|||||||
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
operationRecord = new OperationRecord()
|
||||||
{
|
{
|
||||||
operationRecord = new OperationRecord()
|
FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber,
|
||||||
{
|
SerialNumber = tempSerialNumber,
|
||||||
FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber,
|
PowerStationId = post.PowerStationId,
|
||||||
SerialNumber = tempSerialNumber,
|
WorkType = (int)OperationRecordWorkTypeEnum.Fix,
|
||||||
PowerStationId = post.PowerStationId,
|
ErrorCode = post.ErrorCode,
|
||||||
WorkType = (int)OperationRecordWorkTypeEnum.Fix,
|
FixDo = post.FixDo,
|
||||||
ErrorCode = post.ErrorCode,
|
FixFirm = post.FixFirm,
|
||||||
FixDo = post.FixDo,
|
Status = post.Status,
|
||||||
FixFirm = post.FixFirm,
|
//WorkPersonId = post.WorkPersonId,
|
||||||
Status = post.Status,
|
FinishTime = finishTime,
|
||||||
//WorkPersonId = post.WorkPersonId,
|
WorkTime = post.WorkTime,
|
||||||
FinishTime = finishTime,
|
Notice = post.Notice,
|
||||||
WorkTime = post.WorkTime,
|
Description = post.Description,
|
||||||
Notice = post.Notice,
|
CreatedBy = myUser.Id
|
||||||
Description = post.Description,
|
};
|
||||||
CreatedBy = myUser.Id
|
|
||||||
};
|
|
||||||
|
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
"FormId",
|
"FormId",
|
||||||
"SerialNumber",
|
"SerialNumber",
|
||||||
@ -572,33 +579,104 @@ namespace SolarPower.Controllers
|
|||||||
"CreatedBy"
|
"CreatedBy"
|
||||||
};
|
};
|
||||||
|
|
||||||
id = await operationRepository.AddOneOperationRecordAsync(operationRecord, properties);
|
id = await operationRepository.AddOneOperationRecordAsync(operationRecord, properties);
|
||||||
|
|
||||||
//加入執行人員
|
//加入執行人員
|
||||||
if (post.WorkPersonIds != null)
|
if (post.WorkPersonIds != null)
|
||||||
|
{
|
||||||
|
List<OperationRecordPersonnel> insertOperationRecordPersonnels = new List<OperationRecordPersonnel>();
|
||||||
|
|
||||||
|
foreach (var op in post.WorkPersonIds)
|
||||||
{
|
{
|
||||||
List<OperationRecordPersonnel> insertOperationRecordPersonnels = new List<OperationRecordPersonnel>();
|
OperationRecordPersonnel operationRecordPersonnel = new OperationRecordPersonnel();
|
||||||
|
operationRecordPersonnel.OperationRecordId = id;
|
||||||
|
operationRecordPersonnel.UserId = op;
|
||||||
|
|
||||||
foreach (var op in post.WorkPersonIds)
|
insertOperationRecordPersonnels.Add(operationRecordPersonnel);
|
||||||
{
|
}
|
||||||
OperationRecordPersonnel operationRecordPersonnel = new OperationRecordPersonnel();
|
|
||||||
operationRecordPersonnel.OperationRecordId = id;
|
|
||||||
operationRecordPersonnel.UserId = op;
|
|
||||||
|
|
||||||
insertOperationRecordPersonnels.Add(operationRecordPersonnel);
|
List<string> operationRecordPersonnelProperties = new List<string>()
|
||||||
}
|
|
||||||
|
|
||||||
List<string> operationRecordPersonnelProperties = new List<string>()
|
|
||||||
{
|
{
|
||||||
"OperationRecordId",
|
"OperationRecordId",
|
||||||
"UserId",
|
"UserId",
|
||||||
};
|
};
|
||||||
|
|
||||||
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
||||||
}
|
|
||||||
scope.Complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (post.WorkPersonIds.Count != 0)
|
||||||
|
{
|
||||||
|
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
List<NoticeSchedule> noticeSchedules = new List<NoticeSchedule>();
|
||||||
|
foreach (var person in post.WorkPersonIds)
|
||||||
|
{
|
||||||
|
var fixtype = post.WorkType switch
|
||||||
|
{
|
||||||
|
0 => "清洗",
|
||||||
|
1 => "巡檢",
|
||||||
|
2 => "維修",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
var user = await userRepository.GetOneAsync(person);
|
||||||
|
NoticeSchedule schedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
EmailType = 3,
|
||||||
|
Type = 1,
|
||||||
|
UserId = person,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime,
|
||||||
|
Content = "維修項目" + post.FixDo + "</br>注意事項 :" + post.Notice,
|
||||||
|
};
|
||||||
|
noticeSchedules.Add(schedule);
|
||||||
|
}
|
||||||
|
properties = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Content",
|
||||||
|
"RecipientName",
|
||||||
|
"Type",
|
||||||
|
"ExceptionId"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddAnyThing<List<NoticeSchedule>>(noticeSchedules, properties, "notice_schedule");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post.FixFirm != 0)
|
||||||
|
{
|
||||||
|
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
var fixtype = operationRecord.WorkType switch
|
||||||
|
{
|
||||||
|
0 => "清洗",
|
||||||
|
1 => "巡檢",
|
||||||
|
2 => "維修",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync<OperationInfo>(post.FixFirm, powerstations.SiteDB, "operation_firm");
|
||||||
|
NoticeSchedule schedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
EmailType = 3,
|
||||||
|
Type = 1,
|
||||||
|
RecipientName = firm.Name,
|
||||||
|
RecipientEmail = firm.Email,
|
||||||
|
Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime,
|
||||||
|
Content = "維修項目" + post.FixDo + "</br>注意事項 :" + post.Notice,
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddAnyThing<NoticeSchedule>(schedule, properties, "notice_schedule");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Suppress))
|
||||||
|
//{
|
||||||
|
|
||||||
|
// scope.Complete();
|
||||||
|
//}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
apiResult.Data = id;
|
apiResult.Data = id;
|
||||||
@ -606,9 +684,14 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//var transactionOption = new TransactionOptions();
|
||||||
|
//transactionOption.IsolationLevel = IsolationLevel.ReadUncommitted;
|
||||||
|
//using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOption, TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
//{
|
||||||
|
|
||||||
|
// scope.Complete();
|
||||||
|
//}
|
||||||
#region 修改運維作業記錄
|
#region 修改運維作業記錄
|
||||||
|
|
||||||
var finishTime = string.Empty;
|
var finishTime = string.Empty;
|
||||||
if (post.Status == (int)OperationRecordStatusEnum.Complete)
|
if (post.Status == (int)OperationRecordStatusEnum.Complete)
|
||||||
{
|
{
|
||||||
@ -650,22 +733,20 @@ namespace SolarPower.Controllers
|
|||||||
UpdatedBy = myUser.Id
|
UpdatedBy = myUser.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
"Id",
|
"Id",
|
||||||
"ErrorCode",
|
"ErrorCode",
|
||||||
"FixDo",
|
"FixDo",
|
||||||
"FixFirm",
|
"FixFirm",
|
||||||
"Status",
|
"Status",
|
||||||
"FinishTime",
|
"FinishTime",
|
||||||
"WorkTime",
|
"WorkTime",
|
||||||
"Notice",
|
"Notice",
|
||||||
"Description",
|
"Description",
|
||||||
//"WorkPersonId",
|
//"WorkPersonId",
|
||||||
"UpdatedBy",
|
"UpdatedBy",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(operationRecord.FormId))
|
if (string.IsNullOrEmpty(operationRecord.FormId))
|
||||||
{
|
{
|
||||||
@ -686,7 +767,7 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
//判斷新進來的執行人員是否要歸類到新增 or 刪除
|
//判斷新進來的執行人員是否要歸類到新增 or 刪除
|
||||||
#region 刪除執行人員編號
|
#region 刪除執行人員編號
|
||||||
if(post.WorkPersonIds != null && post.WorkPersonIds.Count() > 0)
|
if (post.WorkPersonIds != null && post.WorkPersonIds.Count() > 0)
|
||||||
{
|
{
|
||||||
//找出要刪除的
|
//找出要刪除的
|
||||||
List<int> deleteOperationRecordPersonnelIds = origOperationRecordPersonnels.Where(x => !post.WorkPersonIds.Contains(x)).ToList();
|
List<int> deleteOperationRecordPersonnelIds = origOperationRecordPersonnels.Where(x => !post.WorkPersonIds.Contains(x)).ToList();
|
||||||
@ -704,7 +785,6 @@ namespace SolarPower.Controllers
|
|||||||
//刪除執行人員
|
//刪除執行人員
|
||||||
await operationRepository.DeleteOperationRecordPersonnel(deleteOperationRecordPersonnels);
|
await operationRepository.DeleteOperationRecordPersonnel(deleteOperationRecordPersonnels);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 新增人員
|
#region 新增人員
|
||||||
@ -725,23 +805,91 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
insertOperationRecordPersonnels.Add(operationPersonnel);
|
insertOperationRecordPersonnels.Add(operationPersonnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> operationRecordPersonnelProperties = new List<string>()
|
List<string> operationRecordPersonnelProperties = new List<string>()
|
||||||
{
|
{
|
||||||
"OperationRecordId",
|
"OperationRecordId",
|
||||||
"Deleted",
|
"Deleted",
|
||||||
"UserId",
|
"UserId",
|
||||||
"CreatedBy",
|
"CreatedBy",
|
||||||
};
|
};
|
||||||
|
|
||||||
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
if (post.WorkPersonIds.Count != 0)
|
||||||
|
{
|
||||||
|
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
List<NoticeSchedule> noticeSchedules = new List<NoticeSchedule>();
|
||||||
|
foreach (var person in post.WorkPersonIds)
|
||||||
|
{
|
||||||
|
var fixtype = operationRecord.WorkType switch
|
||||||
|
{
|
||||||
|
0 => "清洗",
|
||||||
|
1 => "巡檢",
|
||||||
|
2 => "維修",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
var user = await userRepository.GetOneAsync(person);
|
||||||
|
NoticeSchedule schedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
EmailType = 3,
|
||||||
|
Type = 1,
|
||||||
|
UserId = person,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime,
|
||||||
|
Content = "維修項目" + post.FixDo + "</br>注意事項 :" + post.Notice,
|
||||||
|
};
|
||||||
|
noticeSchedules.Add(schedule);
|
||||||
|
}
|
||||||
|
properties = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Content",
|
||||||
|
"RecipientName",
|
||||||
|
"Type",
|
||||||
|
"ExceptionId"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddAnyThing<List<NoticeSchedule>>(noticeSchedules, properties, "notice_schedule");
|
||||||
|
}
|
||||||
|
if (post.FixFirm != 0)
|
||||||
|
{
|
||||||
|
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
var fixtype = post.WorkType switch
|
||||||
|
{
|
||||||
|
0 => "清洗",
|
||||||
|
1 => "巡檢",
|
||||||
|
2 => "維修",
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||||
|
var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync<OperationInfo>(post.FixFirm, powerstations.SiteDB, "operation_firm");
|
||||||
|
NoticeSchedule schedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
EmailType = 3,
|
||||||
|
Type = 1,
|
||||||
|
RecipientName = firm.Name,
|
||||||
|
RecipientEmail = firm.Email,
|
||||||
|
Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime,
|
||||||
|
Content = "維修項目" + post.FixDo + "</br>注意事項 :" + post.Notice,
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddAnyThing<NoticeSchedule>(schedule, properties, "notice_schedule");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
apiResult.Data = operationRecord.Id;
|
apiResult.Data = operationRecord.Id;
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -878,72 +878,90 @@
|
|||||||
|
|
||||||
//#region 儲存表單資料
|
//#region 儲存表單資料
|
||||||
function SaveRecord() {
|
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 ($("#record-form").valid()) {
|
var formData = new FormData();
|
||||||
var url = "/Operation/SaveOperationRecord";
|
|
||||||
|
|
||||||
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) {
|
formData.append("Id", selected_id);
|
||||||
return parseInt(item);
|
formData.append("PowerStationId", $("#power_station_select_modal").val());
|
||||||
})*@
|
formData.append("WorkType", selected_work_type);
|
||||||
|
formData.append("ErrorCode", $("#error_code_modal").val());
|
||||||
formData.append("Id", selected_id);
|
formData.append("FixDo", $("#fix_do_modal").val());
|
||||||
formData.append("PowerStationId", $("#power_station_select_modal").val());
|
formData.append("FixFirm", $("#fix_firm_select_modal").val());
|
||||||
formData.append("WorkType", selected_work_type);
|
formData.append("Status", $("input[name=status_modal]:checked").val());
|
||||||
formData.append("ErrorCode", $("#error_code_modal").val());
|
$("#work_person_select_modal").val().forEach(function (item) {
|
||||||
formData.append("FixDo", $("#fix_do_modal").val());
|
formData.append("WorkPersonIds", parseInt(item));
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
var myDropzone = Dropzone.forElement("#record-file-form");
|
|
||||||
|
|
||||||
if (myDropzone.files.length > 0) {
|
|
||||||
|
|
||||||
selected_id = rel.data;
|
|
||||||
|
|
||||||
myDropzone.processQueue();
|
|
||||||
|
|
||||||
myDropzone.on("successmultiple", function (file, rel) {
|
|
||||||
if (rel.code != "0000") {
|
|
||||||
toast_error(rel.msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
|
||||||
$('#record-form-modal').modal('hide');
|
|
||||||
recordFileDropzone.removeAllFiles();
|
|
||||||
|
|
||||||
operationRecordTable.ajax.reload();
|
|
||||||
});
|
});
|
||||||
} else {
|
formData.append("WorkTime", $("#work_time_modal").val());
|
||||||
$('#record-form-modal').modal('hide');
|
formData.append("Notice", $("#notice_textarea_modal").val());
|
||||||
myDropzone.removeAllFiles();
|
formData.append("Description", $("#description_textarea_modal").val());
|
||||||
|
|
||||||
operationRecordTable.ajax.reload();
|
$.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");
|
||||||
|
|
||||||
|
if (myDropzone.files.length > 0) {
|
||||||
|
|
||||||
|
selected_id = rel.data;
|
||||||
|
|
||||||
|
myDropzone.processQueue();
|
||||||
|
|
||||||
|
myDropzone.on("successmultiple", function (file, rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toast_ok(rel.msg);
|
||||||
|
$('#record-form-modal').modal('hide');
|
||||||
|
recordFileDropzone.removeAllFiles();
|
||||||
|
|
||||||
|
operationRecordTable.ajax.reload();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#record-form-modal').modal('hide');
|
||||||
|
myDropzone.removeAllFiles();
|
||||||
|
|
||||||
|
operationRecordTable.ajax.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|||||||
@ -853,9 +853,16 @@
|
|||||||
$.each(rel.data, function (index, val) {
|
$.each(rel.data, function (index, val) {
|
||||||
$("#ShareDevice_PowerStationId_modal").append($("<option />").val(val.value).text(val.text +"/"+ val.name));
|
$("#ShareDevice_PowerStationId_modal").append($("<option />").val(val.value).text(val.text +"/"+ val.name));
|
||||||
});
|
});
|
||||||
if (rel.data.length > 0)
|
if (rel.data.length > 0) {
|
||||||
{
|
|
||||||
DeviceUIDList($("#ShareDevice_PowerStationId_modal").val());
|
DeviceUIDList($("#ShareDevice_PowerStationId_modal").val());
|
||||||
|
$("#ShareDevice_PowerStationId_modal").attr('disabled', false);
|
||||||
|
$("#ShareDevice-modal").find('.btn-primary').attr('disabled', false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#ShareDevice_PowerStationId_modal").append($("<option />").val("").text("無其餘電站"));
|
||||||
|
$("#ShareDevice_PowerStationId_modal").attr('disabled', true);
|
||||||
|
$("#ShareDevice-modal").find('.btn-primary').attr('disabled', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -938,12 +945,6 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//#region 代管切換
|
//#region 代管切換
|
||||||
@ -2984,6 +2985,38 @@
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$("#Operation-form").validate({
|
||||||
|
rules: {
|
||||||
|
Operation_factory_modal: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
Operation_name_modal: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
Operation_phone_modal: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
Operation_email_modal: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
Operation_role_modal: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("#ShareDevice-form").validate({
|
||||||
|
rules: {
|
||||||
|
ShareDevice_PowerStationId_modal: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
ShareDevice_UID_modal: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function urlApicallItem()
|
function urlApicallItem()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user