-
- 新增廠商資料
+
-
+
- 新增廠商資料
+
+
-
- 選擇功能
+
-
- 選擇功能
+
+
-
-
-
-
- 選擇 | -編號 | -功能名稱 | -
---|---|---|
- | 1 | -系統監控 | -
- | 2 | -歷史資料 | -
- | 3 | -異常記錄 | -
- | 4 | -即時告警 | -
- | 5 | -運維管理 | -
- | 6 | -圖資管理 | -
- | 7 | -帳號管理 | -
-
-
-
+
@@ -282,13 +369,14 @@
$('#startdate, #enddate').on('change', function () {
let startdate = new Date($('#startdate').val());
let enddate = new Date($('#enddate').val());
- setDate(null, startdate, enddate)
+ setDate(null, startdate, enddate);
});
$(`[onclick="setType(null)"]`).click();
initDate();
event();
+ $('div.image-full-show').css("display", "none");
});
function loadOpeFirmTable() {
@@ -344,8 +432,8 @@
"title": "功能",
"data": "id",
"render": function (data) {
- let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }, null, null, {id: data});
- btnDiv.append(creBtnHtml("修改", "opeFirmEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeFirmModal"}));
+ let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }, null, null, { id: data });
+ btnDiv.append(creBtnHtml("修改", "opeFirmEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeFirmModal" }));
btnDiv.append(creBtnHtml("刪除", "opeFirmDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
@@ -370,16 +458,16 @@
let tag = "#opeRecTable";
let column_defs = [
- { "targets": [0], "width": "8%", "sortable": true },
- { "targets": [1], "width": "8%", "sortable": true },
- { "targets": [2], "width": "8%", "sortable": true },
- { "targets": [3], "width": "8%", "sortable": true },
- { "targets": [4], "width": "8%", "sortable": true },
- { "targets": [5], "width": "8%", "sortable": true },
- { "targets": [6], "width": "8%", "sortable": true },
- { "targets": [7], "width": "8%", "sortable": true },
- { "targets": [8], "width": "8%", "sortable": false },
- { "targets": [9], "width": "8%", "sortable": false },
+ { "targets": [0], "width": "2%", "sortable": true },
+ { "targets": [1], "width": "6%", "sortable": true },
+ { "targets": [2], "width": "7%", "sortable": true },
+ { "targets": [3], "width": "6%", "sortable": true },
+ { "targets": [4], "width": "5%", "sortable": true },
+ { "targets": [5], "width": "3%", "sortable": true },
+ { "targets": [6], "width": "5%", "sortable": true },
+ { "targets": [7], "width": "6%", "sortable": true },
+ { "targets": [8], "width": "15%", "sortable": false },
+ { "targets": [9], "width": "6%", "sortable": false },
{ "targets": [10], "width": "8%", "sortable": false },
{ "targets": [11], "width": "8%", "sortable": false },
];
@@ -422,7 +510,23 @@
},
{
"title": "檔案上傳",
- "data": "start_time",
+ "data": "lorf",
+ "render": function (data) {
+ strHtml = ``;
+ $.each(data, function (i, v) {
+ if (i == 0)
+ strHtml += `(sqlString);
}
@@ -1037,7 +1037,7 @@ namespace FrontendWebApi.ApiControllers
}
if (ofl.serial_number != null)
{
- sWhere += $@" and opr.formId like '%@formId%'";
+ sWhere += $@" and opr.formId like '%{ofl.serial_number}%'";
}
var sqlString = $@"select opr.* , concat(d.device_floor_tag, ' ', d.device_last_name, ' ', d.device_serial_tag) as device_name, ui.full_name as user_full_name
@@ -1048,7 +1048,7 @@ namespace FrontendWebApi.ApiControllers
left join userinfo ui on opr.work_person_id = ui.userinfo_guid and ui.deleted = 0
where opr.deleted = 0 and opr.work_type = @work_type" + sWhere;
- var param = new { @work_type = ofl.work_type, @start_created_at = ofl.start_created_at, @end_created_at = ofl.end_created_at, @sub_system_tag = ofl.sub_system_tag, @main_system_tag = ofl.main_system_tag, @formId = ofl.serial_number };
+ var param = new { @work_type = ofl.work_type, @start_created_at = ofl.start_created_at, @end_created_at = ofl.end_created_at, @sub_system_tag = ofl.sub_system_tag, @main_system_tag = ofl.main_system_tag };
orl = await backendRepository.GetAllAsync(sqlString, param);
@@ -1128,7 +1128,7 @@ namespace FrontendWebApi.ApiControllers
///
///
///
- public async Task> SavOpeRecord([FromBody] Operation_Record or)
+ public async Task> SavOpeRecord([FromForm] Operation_Record or)
{
ApiResult apiResult = new ApiResult();
@@ -1144,7 +1144,7 @@ namespace FrontendWebApi.ApiControllers
if (ori == null) //create
{
- var new_guid = new Guid();
+ var new_guid = Guid.NewGuid();
Dictionary operation_record = new Dictionary()
{
{ "@deleted", 0},
@@ -1171,19 +1171,22 @@ namespace FrontendWebApi.ApiControllers
};
await backendRepository.AddOneByCustomTable(operation_record, "operation_record");
- if (or.lorf.Count > 0)
+ if (or.lorf != null)
+ {
+ if (or.lorf.Count > 0)
{
foreach(var orf in or.lorf)
{
sqlString = $@"select id from operation_record where formId = @formId";
var fParam = new { @formId = formId };
var record_id = await backendRepository.GetOneAsync(sqlString, fParam);
+ new_guid = Guid.NewGuid();
Dictionary operation_record_file = new Dictionary()
{
{ "@deleted", 0},
{ "@record_id", record_id},
{ "@ori_file_name", orf.ori_file_name},
- { "@save_file_name", orf.save_file_name},
+ { "@save_file_name", new_guid},
{ "@created_by", myUser.userinfo_guid},
{ "@created_at", DateTime.Now}
};
@@ -1191,7 +1194,6 @@ namespace FrontendWebApi.ApiControllers
if (!System.IO.Directory.Exists(operationFileSaveAsPath))
System.IO.Directory.CreateDirectory(operationFileSaveAsPath);
- new_guid = new Guid();
var fileName = new_guid + "." + orf.ori_file_name.Split('.')[1];
@@ -1205,6 +1207,7 @@ namespace FrontendWebApi.ApiControllers
await backendRepository.AddOneByCustomTable(operation_record_file, "operation_record_file");
}
}
+ }
apiResult.Data = "新增成功";
}
@@ -1232,15 +1235,17 @@ namespace FrontendWebApi.ApiControllers
};
await backendRepository.UpdateOneByCustomTable(operation_record , "operation_record", "id = " + or.id + "");
- if (or.lorf.Count > 0)
+ if (or.lorf != null)
+ {
+ if (or.lorf.Count > 0)
{
foreach(var orf in or.lorf)
{
//刪除原本檔案
- if (orf.id != 0 && orf.save_file_name == null && orf.ori_file_name != null)
+ if (orf.id != 0 && orf.save_file_name != null && orf.ori_file_name != null)
{
//FolderFunction folderFunction = new FolderFunction();
- //folderFunction.DeleteFile(Path.Combine(operationFileSaveAsPath, orf.ori_file_name));
+ //folderFunction.DeleteFile(Path.Combine(operationFileSaveAsPath, orf.save_file_name));
Dictionary operation_record_file = new Dictionary()
{
{ "@deleted", 1},
@@ -1249,12 +1254,13 @@ namespace FrontendWebApi.ApiControllers
}
if (orf.ori_file_name != null && orf.file != null) {
+ var new_guid = Guid.NewGuid();
Dictionary operation_record_file = new Dictionary()
{
{ "@deleted", 0},
- { "@formId", or.formId},
+ { "@record_id", or.id},
{ "@ori_file_name", orf.ori_file_name},
- { "@save_file_name", orf.save_file_name},
+ { "@save_file_name", new_guid},
{ "@created_by", myUser.userinfo_guid},
{ "@created_at", DateTime.Now}
};
@@ -1262,8 +1268,6 @@ namespace FrontendWebApi.ApiControllers
if (!System.IO.Directory.Exists(operationFileSaveAsPath))
System.IO.Directory.CreateDirectory(operationFileSaveAsPath);
- var new_guid = new Guid();
-
var fileName = new_guid + "." + orf.ori_file_name.Split('.')[1];
var fullPath = Path.Combine(operationFileSaveAsPath, fileName);
@@ -1291,7 +1295,7 @@ namespace FrontendWebApi.ApiControllers
// if (!System.IO.Directory.Exists(operationFileSaveAsPath))
// System.IO.Directory.CreateDirectory(operationFileSaveAsPath);
- // var new_guid = new Guid();
+ // var new_guid = Guid.NewGuid();
// var fileName = new_guid + "." + orf.ori_file_name.Split('.')[1];
@@ -1314,6 +1318,7 @@ namespace FrontendWebApi.ApiControllers
//}
}
}
+ }
apiResult.Data = "修改成功";
}
@@ -1347,8 +1352,8 @@ namespace FrontendWebApi.ApiControllers
var param = new { @id = or.id };
var formId = await backendRepository.GetOneAsync(sqlString, param);
- sqlString = @$"UPDATE operation_record_file SET deleted = 1 WHERE formId = @formId";
- var dParam = new { @formId = formId };
+ sqlString = @$"UPDATE operation_record_file SET deleted = 1 WHERE record_id = @record_id";
+ var dParam = new { @record_id = or.id };
await backendRepository.ExecuteSql(sqlString, dParam);
sqlString = @$"UPDATE operation_record SET deleted = 1 WHERE id = @id";
diff --git a/FrontendWebApi/Models/Operation.cs b/FrontendWebApi/Models/Operation.cs
index 94712f0..7f72f17 100644
--- a/FrontendWebApi/Models/Operation.cs
+++ b/FrontendWebApi/Models/Operation.cs
@@ -76,10 +76,10 @@ namespace FrontendWebApi.Models
public int fix_firm { get; set; }
public byte status { get; set; }
public string work_person_id { get; set; }
- public DateTime start_time { get; set; }
- public DateTime end_time { get; set; }
- public DateTime work_time { get; set; }
- public DateTime finish_time { get; set; }
+ public DateTime? start_time { get; set; }
+ public DateTime? end_time { get; set; }
+ public DateTime? work_time { get; set; }
+ public DateTime? finish_time { get; set; }
public string notice { get; set; }
public string description { get; set; }
public string work_type_name
diff --git a/FrontendWebApi/wwwroot/excel/operation/維修.xlsx b/FrontendWebApi/wwwroot/excel/operation/維修.xlsx
new file mode 100644
index 0000000..6b79ec0
Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/operation/維修.xlsx differ
diff --git a/FrontendWebApi/wwwroot/upload/operation/01feac02-0141-4554-99c6-490747c743eb.png b/FrontendWebApi/wwwroot/upload/operation/01feac02-0141-4554-99c6-490747c743eb.png
new file mode 100644
index 0000000..62c1385
Binary files /dev/null and b/FrontendWebApi/wwwroot/upload/operation/01feac02-0141-4554-99c6-490747c743eb.png differ
diff --git a/FrontendWebApi/wwwroot/upload/operation/04e7992a-da7d-4347-9f0c-3e30f65794c4.png b/FrontendWebApi/wwwroot/upload/operation/04e7992a-da7d-4347-9f0c-3e30f65794c4.png
new file mode 100644
index 0000000..62c1385
Binary files /dev/null and b/FrontendWebApi/wwwroot/upload/operation/04e7992a-da7d-4347-9f0c-3e30f65794c4.png differ
diff --git a/FrontendWebApi/wwwroot/upload/operation/21176f4b-b010-4c70-bf6f-e3065fc7e8a2.jpg b/FrontendWebApi/wwwroot/upload/operation/21176f4b-b010-4c70-bf6f-e3065fc7e8a2.jpg
new file mode 100644
index 0000000..2c2bd7d
Binary files /dev/null and b/FrontendWebApi/wwwroot/upload/operation/21176f4b-b010-4c70-bf6f-e3065fc7e8a2.jpg differ
diff --git a/FrontendWebApi/wwwroot/upload/operation/image1.jpg b/FrontendWebApi/wwwroot/upload/operation/6a095414-ceba-47d0-bd57-6193d440640d.jpg
similarity index 100%
rename from FrontendWebApi/wwwroot/upload/operation/image1.jpg
rename to FrontendWebApi/wwwroot/upload/operation/6a095414-ceba-47d0-bd57-6193d440640d.jpg
diff --git a/FrontendWebApi/wwwroot/upload/operation/9fc18636-f154-4409-a69c-fef11a18cb3f.jpg b/FrontendWebApi/wwwroot/upload/operation/9fc18636-f154-4409-a69c-fef11a18cb3f.jpg
new file mode 100644
index 0000000..c002f98
Binary files /dev/null and b/FrontendWebApi/wwwroot/upload/operation/9fc18636-f154-4409-a69c-fef11a18cb3f.jpg differ
`
+ if (i < 3) {
+ let extName = v.ori_file_name.split('.')[1];
+ strHtml += `
+
+ `
+ }
+ });
+ strHtml += `
`;
+
+ return strHtml;
+ }
},
{
"title": "完成時間",
@@ -431,7 +535,6 @@
return displayDate(data, "datetime");
}
},
-
{
"title": "建立時間",
"data": "created_at",
@@ -440,8 +543,9 @@
"title": "功能",
"data": "id",
"render": function (data) {
- let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
- btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "id": data }));
+ let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }, null, null, { id: data });
+ btnDiv.append(creBtnHtml("修改", "opeRecEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeRecModal" }));
+ btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
},
@@ -452,13 +556,13 @@
function setType(wt) {
pageAct.work_type = wt;
-
+
if (wt == null) {
- $('#newForm').data('target', '#opeFirmModal')
+ $('#newForm').attr('data-target', '#opeFirmModal');
loadOpeFirmTable();
}
else {
- $('#newForm').data('target', '#opeRecModal')
+ $('#newForm').attr('data-target', '#opeRecModal');
loadOpeRecTable();
}
}
@@ -493,9 +597,16 @@
pageAct.serial_number = null;
}
+ function clearOpeRecPageAct() {
+ pageAct.selAreaTag = null;
+ pageAct.selBuiTag = null;
+ pageAct.selFloTag = null;
+ }
+
function snSearch() {
clearPageAct();
pageAct.serial_number = $('#serial_number').val() || null;
+ refTable();
}
function initMaiList() {
@@ -556,7 +667,7 @@
startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
enddate: pageAct.enddate == undefined ? null : pageAct.enddate,
};
-
+
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
if (rel.code == "0000")
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + localStorage.getItem("JWT-Authorization");
@@ -570,8 +681,10 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- $("#selSysMain").html();
- $("#selSysSub").html();
+ $("#inpFirmSelSysMain").html();
+ $("#inpFirmSelSysSub").html();
+ $("#inpRecSelSysMain").html();
+ $("#inpRecSelSysSub").html();
strHtml = ``;
$.each(res.data, (index, roleObj) => {
strHtml += ``;
@@ -579,7 +692,8 @@
if (index == 0)
pageAct.selSysMain = tag ?? roleObj.system_value
})
- $("#selSysMain").html(strHtml);
+ $("#inpFirmSelSysMain").html(strHtml);
+ $("#inpRecSelSysMain").html(strHtml);
selSysSub();
}
}, null, "POST").send();
@@ -595,24 +709,187 @@
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
$.each(res.data, (index, roleObj) => {
strHtml += ``;
+ if (index == 0)
+ pageAct.selSysSub = pageAct.selSysSub ?? roleObj.system_value;
})
- $("#selSysSub").html(strHtml);
+ $("#inpFirmSelSysSub").html(strHtml);
+ $("#inpRecSelSysSub").html(strHtml);
+
+ if (pageAct.work_type != null)
+ selArea(pageAct.selAreaTag);
}, null, "POST").send();
}
-
+
+ function selArea(area_tag = null) {
+ let url = baseApiUrl + "/operation/AreaList";
+
+ ytAjax = new YourTeam.Ajax(url, null, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpArea").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ let selected = (area_tag == roleObj.device_area_tag ? 'selected' : '');
+ strHtml += ``;
+
+ if (index == 0)
+ pageAct.selAreaTag = area_tag ?? roleObj.device_area_tag
+ })
+ $("#inpArea").html(strHtml);
+ selBuilding(pageAct.selBuiTag);
+ }
+ }, null, "POST").send();
+ }
+
+ function selBuilding(building_tag = null) {
+ let url = baseApiUrl + "/operation/BuiList";
+
+ sendData = {
+ device_area_tag: pageAct.selAreaTag,
+ };
+ objSendData.Data = sendData;
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpBuilding").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ let selected = (building_tag == roleObj.device_building_tag ? 'selected' : '');
+ strHtml += ``;
+
+ if (index == 0)
+ pageAct.selBuiTag = building_tag ?? roleObj.device_building_tag
+ })
+ $("#inpBuilding").html(strHtml);
+ selFloor(pageAct.selFloTag);
+ }
+ }, null, "POST").send();
+ }
+
+ function selFloor(floor_tag = null) {
+
+ let url = baseApiUrl + "/operation/FloList";
+
+ sendData = {
+ device_building_tag: pageAct.selBuiTag,
+ };
+ objSendData.Data = sendData;
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpFloor").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ let selected = (floor_tag == roleObj.device_floor_tag ? 'selected' : '');
+ strHtml += ``;
+
+ if (index == 0)
+ pageAct.selFloTag = floor_tag ?? roleObj.device_floor_tag
+ })
+ $("#inpFloor").html(strHtml);
+ selDevice();
+ }
+ }, null, "POST").send();
+ }
+
+ function selDevice() {
+ let url = baseApiUrl + "/operation/DevList";
+
+ sendData = {
+ device_area_tag: pageAct.selAreaTag,
+ device_building_tag: pageAct.selBuiTag,
+ device_floor_tag: pageAct.selFloTag,
+ main_system_tag: pageAct.selSysMain,
+ sub_system_tag: pageAct.selSysSub,
+ };
+ objSendData.Data = sendData;
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpFixDoCode").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ strHtml += ``;
+
+ if (index == 0)
+ pageAct.selDevice = roleObj.device_number
+ })
+ $("#inpFixDoCode").html(strHtml);
+ }
+ }, null, "POST").send();
+ }
+
+ function selFixFirm() {
+ let url = baseApiUrl + "/operation/OpeFirList";
+ ytAjax = new YourTeam.Ajax(url, null, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpFixFirm").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ strHtml += ``;
+ })
+ $("#inpFixFirm").html(strHtml);
+ }
+ }, null, "POST").send();
+ }
+
+ function selUser() {
+ let url = baseApiUrl + "/User/UserManagerList";
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $("#inpWorPerId").html();
+ strHtml = ``;
+ $.each(res.data, (index, roleObj) => {
+ strHtml += ``;
+ })
+ $("#inpWorPerId").html(strHtml);
+ }
+ }, null, "POST").send();
+ }
+
+ function selAllSysVal(elem) {
+ //loading process
+ $('#mainList input').map(function (i, v) { $(v).click() });
+ $('#subList input').map(function (i, v) { $(v).click() });
+ //end loading
+
+ $(elem).html($(elem).html() == '全選類別' ? '取消全選' : '全選類別');
+ }
+
function event() {
onEvent('click', '#newForm', function () {
- pageAct.opeFirmAct = 'add';
- $('#opeFirmModal input').map(function (i, v) { $(v).val('') });
+
+ if (pageAct.work_type == null) {
+ pageAct.opeFirmAct = 'add';
+ $('#opeFirmTitle').html('新增廠商資料');
+ $('#opeFirmModal input').map(function (i, v) { $(v).val('') });
+ }
+ else {
+ clearOpeRecPageAct();
+ pageAct.opeRecId = null;
+ pageAct.imageFile = [];
+ $('#opeRecTitle').html(pageAct.work_type == 1 ? "新增保養" : "新增維修");
+ $('#opeRecModal input').map(function (i, v) { $(v).val('') });
+ let today = displayDate(new Date(Date.now()), 'datetime').replaceAll('/', '-');
+ $('#opeRecModal input[id*=Time]').map(function (i, v) { $(v).val(today) });
+ selFixFirm();
+ selUser();
+ $('#forImage').html('');
+ }
+
selSysMain();
});
- onEvent('change', '#selSysMain', function () {
- pageAct.selSysMain = $(this).val();
- selSysSub();
- });
-
onEvent('click', '#opeFirmEdiBtn', function () {
+ $('#opeFirmTitle').html('編輯廠商資料');
let url = baseApiUrl + "/operation/OpeFirRead";
pageAct.opeFirmId = $(this).parent().data('id')
objSendData.Data = { id: pageAct.opeFirmId };
@@ -622,8 +899,8 @@
} else {
pageAct.opeFirmAct = 'edit';
selSysMain(res.data.device_system_category_layer2);
- $('#opeFirmForm select[id=selSysMain]').val(res.data.device_system_category_layer2).change();
- $('#opeFirmForm select[id=selSysSub]').val(res.data.device_system_category_layer3).change();
+ $('#opeFirmForm select[id=inpFirmSelSysMain]').val(res.data.device_system_category_layer2).change();
+ $('#opeFirmForm select[id=inpFirmSelSysSub]').val(res.data.device_system_category_layer3).change();
$('#opeFirmForm input[id=inpName]').val(res.data.name);
$('#opeFirmForm input[id=inpConPer]').val(res.data.contact_person);
$('#opeFirmForm input[id=inpPhone]').val(res.data.phone);
@@ -634,21 +911,21 @@
}, null, "POST").send()
});
- onEvent("click", "#OpeFirmSendBtn", function () {
+ onEvent('click', '#OpeFirmSendBtn', function () {
let form = $("#opeFirmForm");
-
+
$(form).validate({
rules: {
- selSysMain: { required: true },
- selSysSub: { required: true },
+ inpFirmSelSysMain: { required: true },
+ inpFirmSelSysSub: { required: true },
inpName: { required: true, maxlength: 50 }
}
});
if ($(form).valid()) {
let url = baseApiUrl + "/operation/" + (pageAct.opeFirmAct == "add" ? 'SaveOpeFirm' : 'EdtOneOpeFirm');
let sendData = {
- device_system_category_layer2: $('#selSysMain').val(),
- device_system_category_layer3: $('#selSysSub').val(),
+ device_system_category_layer2: $('#inpFirmSelSysMain').val(),
+ device_system_category_layer3: $('#inpFirmSelSysSub').val(),
name: $("#inpName").val() || null,
contact_person: $("#inpConPer").val() || null,
phone: $("#inpPhone").val() || null,
@@ -661,7 +938,7 @@
sendData.id = pageAct.opeFirmId;
objSendData.Data = sendData;
-
+
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
@@ -675,12 +952,13 @@
}
});
- onEvent("click", "#opeFirmDelBtn", function () {
+ onEvent('click', '#opeFirmDelBtn', function () {
+ pageAct.opeRecId = null;
pageAct.opeFirmId = $(this).parent().data('id');
});
- onEvent("click", "#confirmDelBtn", function () {
- objSendData.Data = { id: pageAct.opeFirmId };
+ onEvent('click', '#confirmDelBtn', function () {
+ objSendData.Data = { id: pageAct.opeFirmId ?? pageAct.opeRecId };
let url = baseApiUrl + "/operation/" + (pageAct.work_type == null ? "DelOpeFirm" : "DelOpeRecord");
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
@@ -694,5 +972,229 @@
}
}, null, "DELETE").send();
});
+
+ onEvent('click', '#opeRecDelBtn', function () {
+ pageAct.opeRecId = $(this).parent().data('id');
+ pageAct.opeFirmId = null;
+ });
+
+ onEvent('click', '#OpeRecSendBtn', function () {
+ let form = $("#opeRecForm");
+ let gmtTime = 28800000;
+ $(form).validate({
+ rules: {
+ inpWorTyp: { required: true},
+ inpArea: { required: true },
+ inpBuilding: { required: true },
+ inpFloor: { required: true },
+ inpRecSelSysMain: { required: true },
+ inpRecSelSysSub: { required: true },
+ inpFixDo: { required: true },
+ inpFixDoCode: { required: true },
+ inpFixFirm: { required: true },
+ inpStatus: { required: true },
+ inpWorPerId: { required: true },
+ }
+ });
+
+ if ($(form).valid()) {
+ let url = baseApiUrl + "/operation/SavOpeRecord";
+
+ let fd = new FormData();
+ $.each(pageAct.imageFile, function (i, v) {
+ fd.append("lorf[" + i + "].id", v.id);
+ fd.append("lorf[" + i + "].file", v.file);
+ fd.append("lorf[" + i + "].save_file_name", v.save_file_name);
+ fd.append("lorf[" + i + "].ori_file_name", v.ori_file_name);
+ });
+ fd.append("location", $('#inpArea option:selected').text() + $('#inpBuilding option:selected').text() + $('#inpFloor option:selected').text());
+ fd.append("location_code", $('#inpArea').val().toString() + $('#inpBuilding').val().toString() + $('#inpFloor').val().toString());
+ fd.append("device_system_category_layer2", $('#inpRecSelSysMain').val());
+ fd.append("device_system_category_layer3", $('#inpRecSelSysSub').val());
+ fd.append("work_type", parseInt($('#inpWorTyp').val()));
+ fd.append("fix_do", $('#inpFixDo').val());
+ fd.append("fix_do_code", $('#inpFixDoCode').val());
+ fd.append("fix_firm", parseInt($('#inpFixFirm').val()));
+ fd.append("status", parseInt($('#inpStatus').val()));
+ fd.append("work_person_id", $('#inpWorPerId').val());
+ fd.append("start_time", ($('#inpStaTime').val() || null) == null ? null : new Date($('#inpStaTime').val()).toISOString());
+ fd.append("end_time", ($('#inpEndTime').val() || null) == null ? $('#inpEndTime').val() : new Date($('#inpEndTime').val()).toISOString());
+ fd.append("work_time", ($('#inpWorTime').val() || null) == null ? $('#inpWorTime').val() : new Date($('#inpWorTime').val()).toISOString());
+ fd.append("finish_time", ($('#inpFinTime').val() || null) == null ? null : new Date($('#inpFinTime').val()).toISOString());
+ fd.append("notice", $('#inpNotice').val() || null);
+ fd.append("description", $('#inpDescription').val() || null);
+
+ //let sendData = {
+ // location: $('#inpArea option:selected').text() + $('#inpBuilding option:selected').text() + $('#inpFloor option:selected').text(),
+ // location_code: $('#inpArea').val().toString() + $('#inpBuilding').val().toString() + $('#inpFloor').val().toString(),
+ // device_system_category_layer2: $('#inpRecSelSysMain').val(),
+ // device_system_category_layer3: $('#inpRecSelSysSub').val(),
+ // work_type: parseInt($('#inpWorTyp').val()),
+ // fix_do: $('#inpFixDo').val(),
+ // fix_do_code: $('#inpFixDoCode').val(),
+ // fix_firm: parseInt($('#inpFixFirm').val()),
+ // status: parseInt($('#inpStatus').val()),
+ // work_person_id: $('#inpWorPerId').val(),
+ // start_time: $('#inpStaTime').val() == null ? null : new Date(new Date($('#inpStaTime').val()).getTime() + gmtTime),
+ // end_time: $('#inpEndTime').val() == null ? $('#inpEndTime').val() : new Date(new Date($('#inpEndTime').val()).getTime() + gmtTime),
+ // work_time: $('#inpWorTime').val() == null ? $('#inpWorTime').val() : new Date(new Date($('#inpWorTime').val()).getTime() + gmtTime),
+ // finish_time: $('#inpFinTime').val() == null ? null : new Date(new Date($('#inpFinTime').val()).getTime() + gmtTime),
+ // notice: $('#inpNotice').val() || null,
+ // description: $('#inpDescription').val() || null,
+ // lorf: pageAct.imageFile,
+ //};
+ if (pageAct.opeRecId != null)
+ fd.append("id", pageAct.opeRecId);
+
+ objSendData.Data = sendData;
+ $.ajax({
+ url: url,
+ type: "POST",
+ data: fd,
+ async: false,
+ cache: false,
+ contentType: false,
+ processData: false,
+ beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', "Bearer " + localStorage.getItem("JWT-Authorization")) },
+ success: function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ //toast_ok(common.AddSuc);
+ //$("#opeFirmModal").modal("hide");
+ $("#OpeRecCanBtn").click();
+ refTable();
+ }
+ }
+ });
+
+ //ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ // if (!res || res.code != "0000" || !res.data) {
+
+ // } else {
+ // //toast_ok(common.AddSuc);
+ // //$("#opeFirmModal").modal("hide");
+ // $("#OpeRecCanBtn").click();
+ // refTable();
+ // }
+ //}, null, "POST").send();
+ }
+ });
+
+ onEvent('click', '#opeRecEdiBtn', function () {
+ clearOpeRecPageAct();
+ selFixFirm();
+ selUser();
+ pageAct.imageFile = [];
+ $('#opeRecTitle').html(pageAct.work_type == 1 ? "編輯保養" : "編輯維修");
+ let url = baseApiUrl + "/operation/OpeRecRead";
+ pageAct.opeRecId = $(this).parent().data('id');
+ objSendData.Data = { id: pageAct.opeRecId };
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ pageAct.selBuiTag = res.data.device_building_tag;
+ pageAct.selFloTag = res.data.device_floor_tag;
+ pageAct.selSysSub = res.data.device_system_category_layer3;
+ selSysMain(res.data.device_system_category_layer2);
+ $('#inpArea').val(res.data.device_area_tag);
+ $('#inpBuilding').val(res.data.device_building_tag);
+ $('#inpFloor').val(res.data.device_floor_tag);
+ $('#inpRecSelSysMain').val(res.data.device_system_category_layer2);
+ $('#inpRecSelSysSub').val(res.data.device_system_category_layer3);
+ $('#inpWorTyp').val(res.data.work_type);
+ $('#inpFixDo').val(res.data.fix_do);
+ $('#inpFixDoCode').val(res.data.fix_do_code);
+ $('#inpFixFirm').val(res.data.fix_firm);
+ $('#inpStatus').val(res.data.status);
+ $('#inpWorPerId').val(res.data.work_person_id);
+ $('#inpStaTime').val(displayDate(res.data.start_time, 'datetime').replace(' ', 'T').replaceAll('/', '-'));
+ $('#inpEndTime').val(displayDate(res.data.end_time, 'datetime').replace(' ', 'T').replaceAll('/', '-'));
+ $('#inpWorTime').val(displayDate(res.data.work_time, 'datetime').replace(' ', 'T').replaceAll('/', '-'));
+ $('#inpFinTime').val(displayDate(res.data.finish_time, 'datetime').replace(' ', 'T').replaceAll('/', '-'));
+ $('#inpNotice').val(res.data.notice);
+ $('#inpDescription').val(res.data.description);
+ let strHtml = ``;
+ $.each(res.data.lorf, function (i, v) {
+ let extName = v.ori_file_name.split('.')[1];
+ let divMargin = (i == 0) ? `style='margin-top: 2px'` : ``;
+ strHtml += `
+
+
+
+
+
`;
+ });
+ $('#forImage').html(strHtml);
+ }
+ }, null, "POST").send()
+ });
+
+ onEvent('change', '#inpFirmSelSysMain, #inpRecSelSysMain', function () {
+ pageAct.selSysMain = $(this).val();
+ selSysSub();
+ });
+
+ onEvent("change", "#inpRecSelSysSub", function () {
+ pageAct.selSysSub = $(this).val();
+ selDevice();
+ });
+
+ onEvent("change", "#inpArea", function () {
+ pageAct.selAreaTag = $(this).val();
+ selBuilding();
+ });
+
+ onEvent("change", "#inpBuilding", function () {
+ pageAct.selBuiTag = $(this).val();
+ selFloor();
+ });
+
+ onEvent("change", "#inpFloor", function () {
+ pageAct.selFloTag = $(this).val();
+ selDevice();
+ });
+
+ onEvent("change", "#myImage", function (e) {
+ var imageuploadFormOS = 0;
+ let fileHelper = new YourTeam.Utility.File();
+ //若有文字顯示,清除文字顯示
+ if ($('#forImage p').length > 0) {
+ $("#forImage").html(""); // 清除預覽
+ }
+ //console.log(this.files)
+ imageuploadFormOS = this.files.length;
+ //最多只能上傳幾張
+ let maxlength = $("#forImage").data("maxlength");
+ if (maxlength) {
+ if (imageuploadFormOS + $('#forImage img').length > maxlength) {
+ ShowModal("error", "uplImgOverLen", "無法上傳", "最多只能上傳" + maxlength + "張,您已經超出上傳數量。");
+ $("#myImage").val("");
+ return false;
+ }
+ }
+ fileHelper.readAndPreviewImages(this.files, 'forImage', 150, 70, '', '
');
+ $.each(this.files, function (i, v) {
+ let fd = new FormData();
+ let file = v;
+ fd.append('file', v);
+ pageAct.imageFile.push({ "ori_file_name": v.name, "save_file_name": file.guid, "file": fd.get("file") });
+ });
+ }); //變更圖片
+
+ onEvent("click", "[name=btnDelImg]", function () {
+ elem = $(this).parent();
+ if (elem.attr('data-id'))
+ pageAct.imageFile.push({ "id": elem.data('id'), "ori_file_name": elem.find('img').data('filename'), "save_file_name": elem.find('img').data('savename') });
+ else {
+ pageAct.imageFile =
+ $.grep(pageAct.imageFile, function (image) {
+ return image.save_file_name != elem.find('img').data('savename');
+ });
+ }
+
+ elem.remove();
+ });
}
\ No newline at end of file
diff --git a/Frontend/js/yourteam/yourteam.utility.class.js b/Frontend/js/yourteam/yourteam.utility.class.js
index 1266ee7..afdcccb 100644
--- a/Frontend/js/yourteam/yourteam.utility.class.js
+++ b/Frontend/js/yourteam/yourteam.utility.class.js
@@ -490,7 +490,8 @@ class File {
let height = imgHeight ? imgHeight + "px" : "auto";
let myMath = new YourTeam.Utility.Math();
let myFile = new YourTeam.Utility.File();
- let strExtName = "",strOrgName="";
+ let strExtName = "", strOrgName = "";
+
for (let i = 0; i < files.length; i++) {
let file = files[i];
if (limitMaxSize != null) {
@@ -500,6 +501,8 @@ class File {
}
}
htmlImg = "";
+ let guid = myMath.guid().replace(' ', '');
+ file.guid = guid;
if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
let reader = new FileReader();
@@ -507,13 +510,13 @@ class File {
let image = new Image();
let src = this.result;
image.src = this.result;
-
image.onload = function () {
strExtName = myFile.getFileExtension(file.name);
strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, '');
- htmlImg = frontHtml + ''
+ backHtml;
+
container.insertAdjacentHTML("afterBegin", htmlImg);
//$("[name=" + removeClickTagName + "]").on("click", function (e) {
// e.preventDefault();
diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs
index fe64260..c3b259e 100644
--- a/FrontendWebApi/ApiControllers/OperationController.cs
+++ b/FrontendWebApi/ApiControllers/OperationController.cs
@@ -485,7 +485,7 @@ namespace FrontendWebApi.ApiControllers
}
if (i == 6)
{
- cell.SetCellValue(or.start_time);
+ cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
}
if (i == 7)
{
@@ -539,7 +539,7 @@ namespace FrontendWebApi.ApiControllers
}
if (i == 8)
{
- cell.SetCellValue(or.finish_time);
+ cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
}
if (i == 9)
{
@@ -661,7 +661,7 @@ namespace FrontendWebApi.ApiControllers
}
if (i == 7)
{
- cell.SetCellValue(or.start_time.ToString("yyyy/MM/dd HH:mm:ss"));
+ cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
}
if (i == 8)//image
{
@@ -715,7 +715,7 @@ namespace FrontendWebApi.ApiControllers
}
if (i == 9)
{
- cell.SetCellValue(or.finish_time.ToString("yyyy/MM/dd HH:mm:ss"));
+ cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
}
if (i == 10)
{
@@ -795,7 +795,7 @@ namespace FrontendWebApi.ApiControllers
}
else
{
- var sqlString = $@"select ofi.id, ofi.name from operation_firm where deleted = 0";
+ var sqlString = $@"select id, name from operation_firm where deleted = 0";
opList = await backendRepository.GetAllAsync