[前台] 修改alert 新增維修改api, 修改alert 讀取維修單

This commit is contained in:
dev02 2023-06-07 09:41:23 +08:00
parent e9649bd7f1
commit 8605cf4a01
5 changed files with 263 additions and 10 deletions

View File

@ -208,6 +208,140 @@
</div>
</div>
<!-- Modal center 維修-->
<div class="modal fade" id="alr_opeRecModal_2" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 id="alr_opeRecTitle" class="modal-title">
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<form id="alr_opeRecForm_2">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpNumber_2">表單編號</label>
<input type="text" id="alr_inpNumber_2" name="" class="form-control" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpErrCode_2">異常編號</label>
<select class="form-control" id="alr_inpErrCode_2" name="alr_inpErrCode_2" disabled>
<option value=''>未選擇</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpStaTime_2">預計開始時間</label>
<input type="date" id="alr_inpStaTime_2" name="alr_inpStaTime_2" class="form-control" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpWorTyp_2">項目</label>
<select class="form-control custom-select-ri" id="alr_inpWorTyp_2" name="alr_inpWorTyp_2" disabled>
<option value=2 selected>維修</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpFixDo_2">維修項目</label>
<input type="text" id="alr_inpFixDo_2" name="alr_inpFixDo_2" class="form-control" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpFixDoCode_2">維修項目代碼(設備編號)</label>
<select class="form-control" id="alr_inpFixDoCode_2" name="alr_inpFixDoCode_2" disabled>
<option value=''>未選擇</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpFixFirm_2">負責廠商</label>
<select class="form-control" id="alr_inpFixFirm_2" name="alr_inpFixFirm_2" disabled>
<option value=''>未選擇</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpStatus_2">狀態</label>
<div class="form-control" id="alr_inpStatus_2">
<div class="row container">
<div class="">
<input class="custom-radio-input" type="radio" name="alr_inpSta_2" id="alr_inpSta_2_0" value="0" data-value="0" checked disabled>
<label class="form-label" for="alr_inpSta_0">未完成</label>
</div>
<div class="px-4">
<input class="custom-radio-input" type="radio" name="alr_inpSta_2" id="alr_inpSta_2_1" value="1" data-value="1" disabled>
<label class="form-label" for="alr_inpSta_1">完成</label>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="alr_inpWorPerId_2">工作人員編號</label>
<select class="form-control" id="alr_inpWorPerId_2" name="alr_inpWorPerId_2" disabled>
<option value=''>未選擇</option>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="form-label" for="alr_inpNotice_2">注意事項</label>
<textarea class="form-control" type="text" id="alr_inpNotice_2" name="alr_inpNotice_2" rows="7" disabled></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="form-label" for="alr_inpDescription_2">結果描述</label>
<textarea class="form-control" type="text" id="alr_inpDescription_2" name="alr_inpDescription_2" rows="7" disabled></textarea>
</div>
</div>
<div class="col-md-12">
<label class="form-label">上傳檔案</label>
<div id='alr_ope_forImage_2' class="col-sm-12 forimage mt-2 p-0">
</div>
<div id='alr_ope_forFile_2' class="col-sm-12 forfile mt-2 p-0">
</div>
<div class="form-group dropzone" id="ope_dropZone_2">
<div class="dz-message">
<div class="drag-icon-cph">
<i class="material-icons">backup</i>
</div>
<h3>選擇一個文件或拖放到這裡</h3>
<p class="mb-0 col-grey">
PDF檔案不超過 10MB
</p>
</div>
<div class="fallback">
<input name="file" type="file" multiple disabled />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="alr_OpeRecCanBtn_2" data-dismiss="modal">關閉</button>
</div>
</form>
</div>
</div>
</div>
<script>
pageAct.selSysMain = null;
pageAct.selSysSub = null;
@ -778,7 +912,10 @@
"title": "派工/維運單號",
"data": "formId",
"render": function (data, type, row, meta) {
return data ?? `<td><a href="#" id="alr_recModal" class="btn btn-info" data-toggle="modal" data-target="#alr_opeRecModal" data-system='${row.alarmClass.includes("_") ? row.alarmClass.split('_')[0] + "-" + row.alarmClass.split('_')[1] : row.alarmClass}'>+ 維修單</a></td>`;
return data != null
? `<td><a href="#" id="readOpeRecBtn" data-toggle="modal" data-target="#alr_opeRecModal_2" data-formid="${data}">${data}</a></td>`
: `<td><a href="#" id="alr_recModal" class="btn btn-info" data-toggle="modal" data-target="#alr_opeRecModal" data-system='${row.alarmClass.includes("_") ? row.alarmClass.split('_')[0] + "-" + row.alarmClass.split('_')[1] : row.alarmClass}'>+ 維修單</a></td>`;
}
}
];
@ -809,7 +946,8 @@
function selDevice() {
let url = baseApiUrl + "/operation/DevList";
let lsst = [];
$('input[data-type=sub]').map(function (i, v) { lsst.push($(v).prop('id')); });
lsst.push(pageAct.addSelSub);
//$('input[data-type=sub]').map(function (i, v) { lsst.push($(v).prop('id')); });
sendData = {
device_area_tag: pageAct.AreaTag,
device_building_tag: pageAct.buiTag,
@ -822,6 +960,7 @@
} else {
strHtml = ``;
$("#inpFixDoCode").html();
$("#alr_inpFixDoCode_2").html();
$.each(res.data, (index, roleObj) => {
strHtml += `<option value='${roleObj.device_number}' data-floor=${roleObj.device_floor_tag} data-main=${roleObj.device_system_tag} data-sub=${roleObj.device_name_tag} hidden>${roleObj.device_name}</option>`;
@ -833,6 +972,7 @@
}
})
$("#inpFixDoCode").html(strHtml);
$("#alr_inpFixDoCode_2").html(strHtml);
}
}, null, "POST").send();
}
@ -844,31 +984,38 @@
} else {
$("#inpWorPerId").html();
$("#alr_inpWorPerId_2").html();
strHtml = ``;
strHtml += `<option value=''>未選擇</option>`;
$.each(res.data, (index, roleObj) => {
strHtml += `<option value='${roleObj.userinfo_guid}'>${roleObj.full_name}</option>`;
})
$("#inpWorPerId").html(strHtml);
$("#alr_inpWorPerId_2").html(strHtml);
}
}, null, "POST").send();
}
function selOpeFir() {
let url = baseApiUrl + "/operation/OpeFirSel";
objSendData.Data = { sub_system_tag: $('input[data-type=sub]').map(function (i, v) { return $(v).prop('id'); }).toArray() };
let lsst = [];
lsst.push(pageAct.addSelSub);
objSendData.Data = { sub_system_tag: lsst };
//objSendData.Data = { sub_system_tag: $('input[data-type=sub]').map(function (i, v) { return $(v).prop('id'); }).toArray() };
// console.log(objSendData.Data)
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$("#inpFixFirm").html();
$("#alr_inpFixFirm_2").html();
strHtml = ``;
strHtml += `<option value=''>未選擇</option>`;
$.each(res.data, (index, roleObj) => {
strHtml += `<option value='${roleObj.id}'>${roleObj.name}</option>`;
})
$("#inpFixFirm").html(strHtml);
$("#alr_inpFixFirm_2").html(strHtml);
}
}, null, "POST").send();
}
@ -932,4 +1079,109 @@
$.post(window.location.origin + '/obix/alarm/' + devUuid + '/ack', '<obj is="obix:AckAlarmIn"><str name="ackUser" val="obix" /></obj>', null, "text");
getData();
}
onEvent('click', '#readOpeRecBtn', function () {
selUser();
selDevice();
$('#alr_ope_forImage').html('');
$('#alr_ope_forFile').html('');
$('#alr_ope_forImage_2').html('');
$('#alr_ope_forFile_2').html('');
$('#alr_inpStatus_2 [name=alr_inpSta_2]').prop("disabled", false);
pageAct.imageFile = [];
$('#alr_opeRecTitle').html("讀取維修");
let url = baseApiUrl + "/operation/OpeRecRead";
objSendData.Data = { formId: $(this).data("formid") };
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
pageAct.sysSub = res.data.device_system_category_layer3;
pageAct.number = res.data.fix_do_code;
selOpeFir();
errCodeList();
$('#alr_inpNumber_2').val(res.data.formId);
$('#alr_inpWorTyp_2').val(res.data.work_type);
$('#alr_inpFixDo_2').val(res.data.fix_do);
$('#alr_inpFixDoCode_2').val(res.data.fix_do_code);
$('#alr_inpFixFirm_2').val(res.data.fix_firm);
$('#alr_inpStatus_2 [name=alr_inpSta_2][data-value=' + res.data.status + ']').click();
$('#alr_inpStatus_2 [name=alr_inpSta_2][data-value=' + (res.data.status > 0 ? 0 : 1) + ']').prop("disabled", true);
$('#alr_inpWorPerId_2').val(res.data.work_person_id);
$('#alr_inpStaTime_2').val(displayDate(res.data.start_time, 'date').replaceAll('/', '-'));
$('#alr_inpNotice_2').val(res.data.notice == null ? "" : res.data.notice);
$('#alr_inpDescription_2').val(res.data.description == null ? "" : res.data.description);
ope_imgHtml = null;
$.each(res.data.lorf, function (i, v) {
let extName = v.ori_file_name.split('.')[1];
if (/\.(jpe?g|png|gif)$/i.test(v.ori_file_name)) {
ope_colI = creEle("i", null, null, null, ["fa fa-times"]);
ope_colBtn = creBtn(null, null, "btnDelImg", ["btn-dark m-1"]);
ope_colImg = creImg("img", null, null, null, null, { filename: v.ori_file_name, savename: v.save_file_name }, { style: "margin-left: 30px; margin-top: 10px", height: "70px", width: "70px", src: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName });
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_imgHtml = creEle("span", null, null, null, ["file-item m-1"], { id: v.id }, null);
ope_colA.append(ope_colImg);
ope_imgHtml.append(ope_colA);
ope_colBtn.append(ope_colI);
ope_imgHtml.append(ope_colBtn);
$('#alr_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
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, ["fa fa-times"]);
ope_colBtn = creBtn(null, null, "btnDelImg", ["btn-dark m-1"]);
ope_colBtn.append(ope_colI);
ope_colI = creEle("i", null, null, null, [icons + " fa-3x m-1"]);
ope_colA = creEle("a", v.ori_file_name, null, null, null, null, { href: baseApiUrl + "/upload/operation/" + v.save_file_name + "." + extName, download: v.ori_file_name, target: "_blank" });
ope_imgHtml = creEle("div", null, null, null, ["file-item"], { id: v.id }, null);
ope_imgHtml.append(ope_colI);
ope_imgHtml.append(ope_colA);
ope_imgHtml.append(ope_colBtn);
$('#alr_ope_forFile_2').append(ope_imgHtml ? ope_imgHtml.outerHtml() : null);
}
});
}
}, null, "POST").send()
});
function errCodeList() {
$(loadEle).Loading("start");
let _pathArr = pageAct.number.split("_"); //TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
$(loadEle).Loading("close");
}
function callbackForErr(res) {
res = JSON.parse(res);
strHtml = ``;
$.each(res.data, function (i, v) {
msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : '';
strHtml += `<option value=${v.uuid}>${v.uuid}</option>`;
});
if (res.count > 0)
$('#alr_inpErrCode_2').html(strHtml);
$(loadEle).Loading("close");
}
</script>

View File

@ -1156,7 +1156,7 @@ namespace FrontendWebApi.ApiControllers
from operation_record opr
left join device d on opr.fix_do_code = d.device_number
left join userinfo ui on opr.work_person_id = ui.userinfo_guid
where opr.deleted = 0 and opr.id = @id";
where opr.deleted = 0 and (opr.id = @id or opr.formId = '{ofl.formId}')";
var param = new { @id = ofl.id };
@ -1226,8 +1226,8 @@ namespace FrontendWebApi.ApiControllers
{ "@end_time", or.end_time},
{ "@work_time", or.work_time},
{ "@finish_time", or.finish_time},
{ "@notice", or.notice},
{ "@description", or.description},
{ "@notice", or.notice == "null" ? null : or.notice},
{ "@description", or.description == "null" ? null : or.description},
{ "@created_by", myUser.userinfo_guid},
{ "@created_at", DateTime.Now}
};

View File

@ -47,6 +47,7 @@ namespace FrontendWebApi.Models
public List<string> main_system_tag { get; set; }//大类tag
public List<string> sub_system_tag { get; set; }//小类tag
public byte? work_type { get; set; } // 1:保養, 2:維修
public string formId { get; set; } //異常代碼
}
public class BuildingList

View File

@ -17,8 +17,8 @@
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",

View File

@ -23,8 +23,8 @@
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",