@@ -377,6 +513,7 @@
function loadOpeFirmTable() {
$('#opeFirmTable_wrapper').css('display', 'block');
$('#opeRecTable_wrapper').css('display', 'none');
+ $('#opeRecTable_2_wrapper').css('display', 'none');
$('#serial_number').parent().parent().css('display', 'none');
$('[for=serial_number]').parent().css('display', 'none');
$('#setDate').css('display', 'none');
@@ -443,7 +580,7 @@
function loadOpeRecTable() {
$('#opeFirmTable_wrapper').css('display', 'none');
- $('#opeRecTable_wrapper').css('display', 'block');
+
$('#serial_number').parent().parent().css('display', 'block');
$('[for=serial_number]').parent().css('display', 'block');
$('#setDate').css('display', 'block');
@@ -456,119 +593,236 @@
data: { work_type: pageAct.work_type, start_created_at: pageAct.startdate, end_created_at: pageAct.enddate, serial_number: pageAct.serial_number, main_system_tag: pageAct.main_system_tag, sub_system_tag: pageAct.sub_system_tag }
}
- let tag = "#opeRecTable";
+ let tag = "#opeRecTable" + (pageAct.work_type == "2" ? "_2" : "");
+ let column_defs = [];
+ let columns = [];
+ if (pageAct.work_type == "2") {
+ $('#opeRecTable_wrapper').css('display', 'none');
+ $('#opeRecTable_2_wrapper').css('display', 'block');
- let column_defs = [
- { "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 },
- ];
+ column_defs = [
+ { "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 },
+ ];
- let columns = [
- {
- "title": "項目",
- "data": "work_type_name",
- },
- {
- "title": "位置",
- "data": "location",
- },
- {
- "title": "異常代號",
- "data": "error_code",
- },
- {
- "title": "表單號",
- "data": "formId",
- },
- {
- "title": "設備名稱",
- "data": "device_name",
- },
- {
- "title": "狀態",
- "data": "status_name",
- },
- {
- "title": "處理人員",
- "data": "user_full_name",
- },
- {
- "title": "預計施工時間",
- "data": "start_time",
- "render": function (data) {
- return displayDate(data, "datetime");
- }
- },
- {
- "title": "檔案上傳",
- "data": "lorf",
- "render": function (data) {
- ope_imgHtml = null;
- $.each(data, function (i, v) {
- let extName = v.ori_file_name.split('.')[1];
- if (i == 0)
- ope_imgHtml = creDiv(["file-item"], null, null, null, { id: v.id });
- if (i < 3) {
- if (/\.(jpe?g|png|gif)$/i.test(v.ori_file_name)) {
- ope_colA = creEle("a", null, null, null, null, null, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, target: "_blank" });
- ope_colImg = creImg("img", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { style: "margin-left: 30px", height: "70px", width: "50px", src: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName });
- ope_colA.append(ope_colImg);
- ope_imgHtml.append(ope_colA);
+ columns = [
+ {
+ "title": "項目",
+ "data": "work_type_name",
+ },
+ {
+ "title": "位置",
+ "data": "location",
+ },
+ {
+ "title": "異常代號",
+ "data": "error_code",
+ },
+ {
+ "title": "表單號",
+ "data": "formId",
+ },
+ {
+ "title": "設備名稱",
+ "data": "device_name",
+ },
+ {
+ "title": "狀態",
+ "data": "status_name",
+ },
+ {
+ "title": "處理人員",
+ "data": "user_full_name",
+ },
+ {
+ "title": "預計施工時間",
+ "data": "start_time",
+ "render": function (data) {
+ return displayDate(data, "datetime");
+ }
+ },
+ {
+ "title": "檔案上傳",
+ "data": "lorf",
+ "render": function (data) {
+ ope_imgHtml = null;
+ $.each(data, function (i, v) {
+ let extName = v.ori_file_name.split('.')[1];
+ if (i == 0)
+ ope_imgHtml = creDiv(["file-item"], null, null, null, { id: v.id });
+ if (i < 3) {
+ if (/\.(jpe?g|png|gif)$/i.test(v.ori_file_name)) {
+ ope_colA = creEle("a", null, null, null, null, null, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, target: "_blank", style: "cursor: pointer" });
+ ope_colImg = creImg("img", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { style: "margin-left: 30px", height: "70px", width: "50px", src: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName });
+ ope_colA.append(ope_colImg);
+ ope_imgHtml.append(ope_colA);
+ }
+ else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(v.ori_file_name)) {
+ icons = null
+ if (extName == "xlsx" || extName == xls)
+ icons = "fas fa-file-excel";
+ else if (extName == "pdf" || extName == "ods")
+ icons = "fas fa-file-pdf";
+ else if (extName == "doc" || extName == "docx")
+ icons = "fas fa-file-word";
+ else
+ icons = "fas fa-file-alt";
+
+ ope_colI = creEle("i", null, null, null, [icons + " fa-3x m-1"]);
+ ope_colA = creEle("a", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, style: "margin-left: 30px" });
+ ope_colA.append(ope_colI);
+ ope_imgHtml.append(ope_colA);
+ }
}
- else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(v.ori_file_name)) {
- icons = null
- if (extName == "xlsx" || extName == xls)
- icons = "fas fa-file-excel";
- else if (extName == "pdf" || extName == "ods")
- icons = "fas fa-file-pdf";
- else if (extName == "doc" || extName == "docx")
- icons = "fas fa-file-word";
- else
- icons = "fas fa-file-alt";
+ });
- ope_colI = creEle("i", null, null, null, [icons + " fa-3x m-1"]);
- ope_colA = creEle("a", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, style: "margin-left: 30px" });
- ope_colA.append(ope_colI);
- ope_imgHtml.append(ope_colA);
+ return ope_imgHtml ? ope_imgHtml.outerHtml() : null;
+ }
+ },
+ {
+ "title": "完成時間",
+ "data": "finish_time",
+ "render": function (data) {
+ return displayDate(data, "datetime");
+ }
+ },
+ {
+ "title": "建立時間",
+ "data": "created_at",
+ },
+ {
+ "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("修改", "opeRecEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeRecModal_2" }));
+ btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
+ return btnDiv.outerHtml();
+ }
+ },
+ ];
+ }
+ else if (pageAct.work_type == "1") {
+ $('#opeRecTable_wrapper').css('display', 'block');
+ $('#opeRecTable_2_wrapper').css('display', 'none');
+
+ column_defs = [
+ { "targets": [0], "width": "2%", "sortable": true },
+ { "targets": [1], "width": "6%", "sortable": true },
+ { "targets": [2], "width": "6%", "sortable": true },
+ { "targets": [3], "width": "5%", "sortable": true },
+ { "targets": [4], "width": "3%", "sortable": true },
+ { "targets": [5], "width": "5%", "sortable": true },
+ { "targets": [6], "width": "6%", "sortable": true },
+ { "targets": [7], "width": "15%", "sortable": false },
+ { "targets": [8], "width": "6%", "sortable": false },
+ { "targets": [9], "width": "8%", "sortable": false },
+ { "targets": [10], "width": "8%", "sortable": false },
+ ];
+
+ columns = [
+ {
+ "title": "項目",
+ "data": "work_type_name",
+ },
+ {
+ "title": "位置",
+ "data": "location",
+ },
+ {
+ "title": "表單號",
+ "data": "formId",
+ },
+ {
+ "title": "設備名稱",
+ "data": "device_name",
+ },
+ {
+ "title": "狀態",
+ "data": "status_name",
+ },
+ {
+ "title": "處理人員",
+ "data": "user_full_name",
+ },
+ {
+ "title": "預計施工時間",
+ "data": "start_time",
+ "render": function (data) {
+ return displayDate(data, "datetime");
+ }
+ },
+ {
+ "title": "檔案上傳",
+ "data": "lorf",
+ "render": function (data) {
+ ope_imgHtml = null;
+ $.each(data, function (i, v) {
+ let extName = v.ori_file_name.split('.')[1];
+ if (i == 0)
+ ope_imgHtml = creDiv(["file-item"], null, null, null, { id: v.id });
+ if (i < 3) {
+ if (/\.(jpe?g|png|gif)$/i.test(v.ori_file_name)) {
+ ope_colA = creEle("a", null, null, null, null, null, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, target: "_blank", style: "cursor: pointer" });
+ ope_colImg = creImg("img", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { style: "margin-left: 30px", height: "70px", width: "50px", src: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName });
+ ope_colA.append(ope_colImg);
+ ope_imgHtml.append(ope_colA);
+ }
+ else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(v.ori_file_name)) {
+ icons = null
+ if (extName == "xlsx" || extName == xls)
+ icons = "fas fa-file-excel";
+ else if (extName == "pdf" || extName == "ods")
+ icons = "fas fa-file-pdf";
+ else if (extName == "doc" || extName == "docx")
+ icons = "fas fa-file-word";
+ else
+ icons = "fas fa-file-alt";
+
+ ope_colI = creEle("i", null, null, null, [icons + " fa-3x m-1"]);
+ ope_colA = creEle("a", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, style: "margin-left: 30px" });
+ ope_colA.append(ope_colI);
+ ope_imgHtml.append(ope_colA);
+ }
}
- }
- });
+ });
- return ope_imgHtml ? ope_imgHtml.outerHtml() : null;
- }
- },
- {
- "title": "完成時間",
- "data": "finish_time",
- "render": function (data) {
- return displayDate(data, "datetime");
- }
- },
- {
- "title": "建立時間",
- "data": "created_at",
- },
- {
- "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("修改", "opeRecEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeRecModal" }));
- btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
- return btnDiv.outerHtml();
- }
- },
- ];
+ return ope_imgHtml ? ope_imgHtml.outerHtml() : null;
+ }
+ },
+ {
+ "title": "完成時間",
+ "data": "finish_time",
+ "render": function (data) {
+ return displayDate(data, "datetime");
+ }
+ },
+ {
+ "title": "建立時間",
+ "data": "created_at",
+ },
+ {
+ "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("修改", "opeRecEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeRecModal" }));
+ btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
+ return btnDiv.outerHtml();
+ }
+ },
+ ];
+ }
opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
@@ -581,8 +835,8 @@
loadOpeFirmTable();
}
else {
- $('#inpWorTyp').val(wt);
- $('#newForm').attr('data-target', '#opeRecModal');
+ $(pageAct.work_type == '1' ? '#inpWorTyp' : '#inpWorTyp_2').val(wt);
+ $('#newForm').attr('data-target', pageAct.work_type == "1" ? '#opeRecModal' : '#opeRecModal_2');
loadOpeRecTable();
}
}
@@ -720,7 +974,7 @@
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");
+ location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
}, null, "POST").send();
}
@@ -758,7 +1012,7 @@
} else {
strHtml = ``;
- $("#inpFixDoCode").html();
+ $(pageAct.work_type == '1' ? "#inpFixDoCode" : "#inpFixDoCode_2").html();
$.each(res.data, (index, roleObj) => {
strHtml += `
`;
@@ -769,7 +1023,7 @@
pageAct.number = roleObj.device_number;
}
})
- $("#inpFixDoCode").html(strHtml);
+ $(pageAct.work_type == '1' ? "#inpFixDoCode" : "#inpFixDoCode_2").html(strHtml);
}
}, null, "POST").send();
}
@@ -780,13 +1034,13 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- $("#inpWorPerId").html();
+ $(pageAct.work_type == '1' ? "#inpWorPerId" : "#inpWorPerId_2").html();
strHtml = ``;
strHtml += `
`;
$.each(res.data, (index, roleObj) => {
strHtml += `
`;
})
- $("#inpWorPerId").html(strHtml);
+ $(pageAct.work_type == '1' ? "#inpWorPerId" : "#inpWorPerId_2").html(strHtml);
}
}, null, "POST").send();
}
@@ -798,13 +1052,13 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- $("#inpFixFirm").html();
+ $(pageAct.work_type == '1' ? "#inpFixFirm" : "#inpFixFirm_2").html();
strHtml = ``;
strHtml += `
`;
$.each(res.data, (index, roleObj) => {
strHtml += `
`;
})
- $("#inpFixFirm").html(strHtml);
+ $(pageAct.work_type == '1' ? "#inpFixFirm" : "#inpFixFirm_2").html(strHtml);
}
}, null, "POST").send();
}
@@ -847,23 +1101,28 @@
pageAct.opeFirmAct = 'add';
$('#opeFirmTitle').html('新增廠商資料');
$('#opeFirmModal input').map(function (i, v) { $(v).val('') });
+ $('#opeFirmModal [id*=-error]').hide();
}
else {
clearOpeRecPageAct();
+ $('#' + (pageAct.work_type == '1' ? 'opeRecForm' : 'opeRecForm_2') + ' [id*=-error]').hide();
pageAct.opeRecId = null;
pageAct.imageFile = [];
- $('#opeRecTitle').html(pageAct.work_type == 1 ? "新增保養" : "新增維修");
- $('#opeRecModal input').map(function (i, v) { $(v).val('') });
+ $(pageAct.work_type == '1' ? '#opeRecTitle' : '#opeRecTitle_2').html(pageAct.work_type == 1 ? "新增保養" : "新增維修");
+ $(pageAct.work_type == '1' ? '#opeRecModal input' : '#opeRecModal_2 input').map(function (i, v) { $(v).val('') });
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
- $('#opeRecModal input[id*=Time]').map(function (i, v) { $(v).val(today) });
- $('#ope_forImage').html('');
- $('#ope_forFile').html('');
- $('#inpDescription').val('');
- $('#inpNotice').val('');
+ $(pageAct.work_type == '1' ? '#opeRecModal input[id*=Time]' : '#opeRecModal_2 input[id*=Time]').map(function (i, v) { $(v).val(today) });
+ $(pageAct.work_type == '1' ? '#ope_forImage' : '#ope_forImage_2').html('');
+ $(pageAct.work_type == '1' ? '#ope_forFile' : '#ope_forFile_2').html('');
+ $(pageAct.work_type == '1' ? '#inpDescription' : '#inpDescription_2').val('');
+ $(pageAct.work_type == '1' ? '#inpNotice' : '#inpNotice_2').val('');
+ $(pageAct.work_type == '1' ? '#inpFixDo' : '#inpFixDo_2').val('');
selUser();
selDevice();
selOpeFir();
errCodeList();
+ getFormId();
+ getUser();
}
selSysMain();
@@ -923,7 +1182,7 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- //toast_ok(common.AddSuc);
+ toast_ok(common.AddSuc);
//$("#opeFirmModal").modal("hide");
$("#OpeFirmCanBtn").click();
refTable();
@@ -945,7 +1204,7 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- //toast_ok(common.AddSuc);
+ toast_ok(common.DelSuc);
//$("#delModal").modal("hide");
$("#confirmDelCanBtn").click();
refTable();
@@ -958,18 +1217,32 @@
pageAct.opeFirmId = null;
});
- onEvent('click', '#OpeRecSendBtn', function () {
- let form = $("#opeRecForm");
- $(form).validate({
- rules: {
- inpWorTyp: { required: true },
- inpFixDo: { required: true },
- inpFixDoCode: { required: true },
- inpFixFirm: { required: true },
- inpStatus: { required: true },
- inpWorPerId: { required: true },
- }
- });
+ onEvent('click', '#OpeRecSendBtn, #OpeRecSendBtn_2', function () {
+ let form = $(pageAct.work_type == '1' ? "#opeRecForm" : "#opeRecForm_2");
+ if (pageAct.work_type == '1') {
+ $(form).validate({
+ rules: {
+ inpWorTyp: { required: true },
+ inpFixDo: { required: true },
+ inpFixDoCode: { required: true },
+ inpFixFirm: { required: true },
+ inpStatus: { required: true },
+ inpWorPerId: { required: true },
+ }
+ });
+ }
+ else {
+ $(form).validate({
+ rules: {
+ inpWorTyp_2: { required: true },
+ inpFixDo_2: { required: true },
+ inpFixDoCode_2: { required: true },
+ inpFixFirm_2: { required: true },
+ inpStatus_2: { required: true },
+ inpWorPerId_2: { required: true },
+ }
+ });
+ }
if ($(form).valid()) {
let url = baseApiUrl + "/operation/SavOpeRecord";
@@ -982,23 +1255,23 @@
fd.append("lorf[" + i + "].ori_file_name", v.ori_file_name);
});
- fd.append("error_code", $('#inpErrCode').val());
+ fd.append("error_code", $(pageAct.work_type == "1" ? '#inpErrCode' : '#inpErrCode_2').val());
fd.append("location", "台北" + $('#buiActDrop').text() + pageAct.floor);
fd.append("location_code", pageAct.AreaTag + pageAct.buiTag + pageAct.floor);
fd.append("device_system_category_layer2", pageAct.sysMain);
fd.append("device_system_category_layer3", pageAct.sysSub);
- 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("work_type", parseInt($(pageAct.work_type == "1" ? '#inpWorTyp' : '#inpWorTyp_2').val()));
+ fd.append("fix_do", $(pageAct.work_type == "1" ? '#inpFixDo' : '#inpFixDo_2').val());
+ fd.append("fix_do_code", $(pageAct.work_type == "1" ? '#inpFixDoCode' : '#inpFixDoCode_2').val());
+ fd.append("fix_firm", parseInt($(pageAct.work_type == "1" ? '#inpFixFirm' : '#inpFixFirm_2').val()));
+ fd.append("status", parseInt($('#' + (pageAct.work_type == '1' ? 'inpStatus' : 'inpStatus_2') + ' [name=' + (pageAct.work_type == '1' ? 'inpSta' : 'inpSta_2') + ']:checked').data('value')));
+ fd.append("work_person_id", $(pageAct.work_type == "1" ? '#inpWorPerId' : '#inpWorPerId_2').val());
+ fd.append("start_time", ($(pageAct.work_type == "1" ? '#inpStaTime' : '#inpStaTime_2').val() || null) == null ? null : new Date($(pageAct.work_type == "1" ? '#inpStaTime' : '#inpStaTime_2').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);
+ fd.append("finish_time", (parseInt($('#' + (pageAct.work_type == '1' ? 'inpStatus' : 'inpStatus_2') + ' [name=' + (pageAct.work_type == '1' ? 'inpSta' : 'inpSta_2') + ']:checked').data('value'))) == 1 ? new Date(Date.now()).toISOString() : null);
+ fd.append("notice", $(pageAct.work_type == "1" ? '#inpNotice' : '#inpNotice_2').val() || null);
+ fd.append("description", $(pageAct.work_type == "1" ? '#inpDescription' : '#inpDescription_2').val() || null);
//let sendData = {
// location: $('#inpArea option:selected').text() + $('#inpBuilding option:selected').text() + $('#inpFloor option:selected').text(),
@@ -1031,29 +1304,18 @@
cache: false,
contentType: false,
processData: false,
- beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', "Bearer " + localStorage.getItem("JWT-Authorization")) },
+ beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', "Bearer " + cookies.get("JWT-Authorization")) },
success: function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
- //toast_ok(common.AddSuc);
+ toast_ok(common.AddSuc);
//$("#opeFirmModal").modal("hide");
- $("#OpeRecCanBtn").click();
+ $(pageAct.work_type == '1' ? "#OpeRecCanBtn" : "#OpeRecCanBtn_2").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();
}
});
@@ -1064,6 +1326,8 @@
$('#ope_forImage').html('');
$('#ope_forFile').html('');
+ $('#ope_forImage_2').html('');
+ $('#ope_forFile_2').html('');
pageAct.imageFile = [];
$('#opeRecTitle').html(pageAct.work_type == 1 ? "編輯保養" : "編輯維修");
@@ -1076,18 +1340,18 @@
} else {
pageAct.sysSub = res.data.device_system_category_layer3;
pageAct.number = res.data.fix_do_code;
-
selOpeFir();
errCodeList();
- $('#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, 'date').replaceAll('/', '-'));
- $('#inpNotice').text(res.data.notice);
- $('#inpDescription').text(res.data.description);
+ $(pageAct.work_type == "1" ? '#inpNumber' : '#inpNumber_2').val(res.data.formId);
+ $(pageAct.work_type == "1" ? '#inpWorTyp' : '#inpWorTyp_2').val(res.data.work_type);
+ $(pageAct.work_type == "1" ? '#inpFixDo' : '#inpFixDo_2').val(res.data.fix_do);
+ $(pageAct.work_type == "1" ? '#inpFixDoCode' : '#inpFixDoCode_2').val(res.data.fix_do_code);
+ $(pageAct.work_type == "1" ? '#inpFixFirm' : '#inpFixFirm_2').val(res.data.fix_firm);
+ $('#' + (pageAct.work_type == '1' ? 'inpStatus' : 'inpStatus_2') + ' [name=' + (pageAct.work_type == '1' ? 'inpSta' : 'inpSta_2') + '][data-value=' + res.data.status + ']').click();
+ $(pageAct.work_type == "1" ? '#inpWorPerId' : '#inpWorPerId_2').val(res.data.work_person_id);
+ $(pageAct.work_type == "1" ? '#inpStaTime' : '#inpStaTime_2').val(displayDate(res.data.start_time, 'date').replaceAll('/', '-'));
+ $(pageAct.work_type == "1" ? '#inpNotice' : '#inpNotice_2').val(res.data.notice);
+ $(pageAct.work_type == "1" ? '#inpDescription' : '#inpDescription_2').val(res.data.description);
ope_imgHtml = null;
$.each(res.data.lorf, function (i, v) {
@@ -1106,7 +1370,7 @@
ope_imgHtml.append(ope_colA);
ope_colBtn.append(ope_colI);
ope_imgHtml.append(ope_colBtn);
- $('#ope_forImage').append(ope_imgHtml ? ope_imgHtml.outerHtml() : null);
+ $(pageAct.work_type == "1" ? '#ope_forImage' : '#ope_forImage_2').append(ope_imgHtml ? ope_imgHtml.outerHtml() : null);
}
else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(v.ori_file_name)) {
icons = null
@@ -1130,7 +1394,7 @@
ope_imgHtml.append(ope_colI);
ope_imgHtml.append(ope_colA);
ope_imgHtml.append(ope_colBtn);
- $('#ope_forFile').append(ope_imgHtml ? ope_imgHtml.outerHtml() : null);
+ $(pageAct.work_type == "1" ? '#ope_forFile' : '#ope_forFile_2').append(ope_imgHtml ? ope_imgHtml.outerHtml() : null);
}
});
}
@@ -1164,7 +1428,7 @@
$($(`#inpFirmSelSysSub option[data-main=${mainTag}]`)[0]).attr('selected', 'selected')
});
- onEvent("change", "#inpFixDoCode", function () {
+ onEvent("change", "#inpFixDoCode, #inpFixDoCode_2", function () {
elemSel = $(this).find('option:selected');
pageAct.sysSub = elemSel.data('sub');
pageAct.sysMain = elemSel.data('main');
@@ -1188,18 +1452,18 @@
$.each(res.data, function (i, v) {
msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : '';
- strHtml += `
`;
+ strHtml += `
`;
});
if (res.count > 0)
- $('#inpErrCode').html(strHtml);
+ $(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml);
$(loadEle).Loading("close");
}
//上傳檔案 dropzone
function initDropzone() {
- uploader = $("#ope_dropZone").dropzone({
+ $("#ope_dropZone").dropzone({
url: baseApiUrl + '/api/Upload',
previewsContainer: false,
addRemoveLinks: false,
@@ -1207,11 +1471,11 @@
dictInvalidFileType: `上傳格式錯誤`,
dictCancelUploadConfirmation: `確定要取消上傳此檔案嗎?`,
dictCancelUpload: `
cancel`,
- maxFilesize: 3,
+ maxFilesize: 10,
filesizeBase: 1024,
maxFiles: 50,
acceptedFiles: ".pdf, .docx, .doc, .xls, .xlsm, .xlsx, .ppt, .pptx, .gif, .png, .jpg, .jpeg",
- headers: { "Authorization": 'Bearer ' + localStorage.getItem("JWT-Authorization") },
+ headers: { "Authorization": 'Bearer ' + cookies.get("JWT-Authorization") },
accept: function (file, done) {
let fileHelper = new YourTeam.Utility.File();
tmpGuidArr = [];
@@ -1240,5 +1504,67 @@
}
}
});
+
+ $("#ope_dropZone_2").dropzone({
+ url: baseApiUrl + '/api/Upload',
+ previewsContainer: false,
+ addRemoveLinks: false,
+ dictRemoveFile: `
delete`,
+ dictInvalidFileType: `上傳格式錯誤`,
+ dictCancelUploadConfirmation: `確定要取消上傳此檔案嗎?`,
+ dictCancelUpload: `
cancel`,
+ maxFilesize: 10,
+ filesizeBase: 1024,
+ maxFiles: 50,
+ acceptedFiles: ".pdf, .docx, .doc, .xls, .xlsm, .xlsx, .ppt, .pptx, .gif, .png, .jpg, .jpeg",
+ headers: { "Authorization": 'Bearer ' + cookies.get("JWT-Authorization") },
+ accept: function (file, done) {
+ let fileHelper = new YourTeam.Utility.File();
+ tmpGuidArr = [];
+
+ if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
+ fileHelper.readAndPreviewImages(file, 'ope_forImage_2', 70, 70, '
', '');
+
+ pageAct.imageFile.map(function (v, i) { if (v['file']) tmpGuidArr.push(v.file.guid); });
+ if (jQuery.inArray(file.guid, tmpGuidArr) == -1) { //not in array
+ let fd = new FormData();
+ let f = file;
+ fd.append('file', f);
+ pageAct.imageFile.push({ "ori_file_name": f.name, "save_file_name": f.guid, "file": fd.get("file") });
+ }
+ }
+ else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) {
+ fileHelper.readAndPreviewFiles(file, 'ope_forFile_2', 70, 70, "
", "
");
+
+ pageAct.imageFile.map(function (v, i) { if (v['file']) tmpGuidArr.push(v.file.guid); });
+ if (jQuery.inArray(file.guid, tmpGuidArr) == -1) { //not in array
+ let fd = new FormData();
+ let f = file;
+ fd.append('file', f);
+ pageAct.imageFile.push({ "ori_file_name": f.name, "save_file_name": f.guid, "file": fd.get("file") });
+ }
+ }
+ }
+ });
+ }
+
+ function getFormId() {
+ ytAjax = new YourTeam.Ajax(baseApiUrl + '/operation/GetFormId', objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $(pageAct.work_type == '1' ? '#inpNumber' : '#inpNumber_2').val(res.data);
+ }
+ }, null, "POST").send();
+ }
+
+ function getUser() {
+ ytAjax = new YourTeam.Ajax(baseApiUrl + "/api/getUser", null, function (res) {
+ if (!res || res.code != "0000" || !res.data) {
+
+ } else {
+ $(pageAct.work_type == '1' ? '#inpWorPerId' : '#inpWorPerId_2').val(res.data);
+ }
+ }, null, "POST").send();
}
\ No newline at end of file
diff --git a/Frontend/js/site.js b/Frontend/js/site.js
index d9d3b38..e48d498 100644
--- a/Frontend/js/site.js
+++ b/Frontend/js/site.js
@@ -167,7 +167,7 @@ function creSelect(id = null, cls = [], name = null, data = {}, attr = {}, text
}
function creOption(text = null, value = null, data = {}, attr = {}, cls = [], name = null, id = null) {
- attr = value != null ? attr.value = value : attr;
+ value != null ? attr.value = value : attr;
return creEle("option", text, id, name, cls, data, attr);
}
diff --git a/Frontend/js/style.js b/Frontend/js/style.js
index aea62e5..26c4ffd 100644
--- a/Frontend/js/style.js
+++ b/Frontend/js/style.js
@@ -166,7 +166,7 @@ function jquValAddMethod() {
}, "請輸入正確電話號碼格式");
$.validator.addMethod("dbLimit", function (value, element, param) {
- return value.length > param;
+ return value.length < param;
}, "超出輸入限制");
}
}
diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs
index af5a3ef..6d7541d 100644
--- a/FrontendWebApi/ApiControllers/OperationController.cs
+++ b/FrontendWebApi/ApiControllers/OperationController.cs
@@ -22,6 +22,8 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Image = System.Drawing.Image;
+using System.IdentityModel.Tokens.Jwt;
+using System.Net;
namespace FrontendWebApi.ApiControllers
{
@@ -1403,6 +1405,33 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+
+ ///
+ /// 獲取維修/保養 單號
+ ///
+ ///
+ public async Task
> GetFormId()
+ {
+ ApiResult apiResult = new ApiResult();
+
+ try
+ {
+ var sqlString = $@"select formId from operation_record where convert(created_at, DATE) = convert(NOW(), DATE) order by id desc limit 1";
+ var formId = await backendRepository.GetOneAsync(sqlString);
+ formId = formId != null ? "op" + DateTime.Now.ToString("yyyyMMdd") + (Int32.Parse(formId.Substring(10)) + 1).ToString().PadLeft(3, '0') : "op" + DateTime.Now.ToString("yyyyMMdd") + "001";
+
+ apiResult.Code = "0000";
+ apiResult.Data = formId;
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
#endregion
}
}
diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs
index 01d4d5d..8944159 100644
--- a/FrontendWebApi/ApiControllers/UserController.cs
+++ b/FrontendWebApi/ApiControllers/UserController.cs
@@ -9,7 +9,9 @@ using Repository.BaseRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
using System.Linq;
+using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
@@ -662,5 +664,16 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+
+ [HttpPost]
+ [Route("api/getUser")]
+ public ActionResult GetUser()
+ {
+ return Json(new
+ {
+ code = "0000",
+ data = myUser.userinfo_guid
+ });
+ }
}
}