806 lines
32 KiB
Plaintext
806 lines
32 KiB
Plaintext
@{
|
|
ViewData["MainNum"] = "1";
|
|
ViewData["SubNum"] = "1";
|
|
ViewData["Title"] = "設備類別管理";
|
|
}
|
|
|
|
<ol class="breadcrumb page-breadcrumb">
|
|
<li class="breadcrumb-item"><a href="javascript:void(0);">設備系統基本資料</a></li>
|
|
<li class="breadcrumb-item active">設備類別管理</li>
|
|
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
|
|
</ol>
|
|
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div id="panel-5" class="panel">
|
|
<div class="panel-container show">
|
|
<div class="panel-content">
|
|
<ul class="nav nav-tabs" id="tabs" role="tablist">
|
|
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#tab-system-main" role="tab"><span class="hidden-sm-down ml-1">系統大類</span></a></li>
|
|
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-system-sub" role="tab"><span class="hidden-sm-down ml-1">系統小類</span></a></li>
|
|
</ul>
|
|
<div class="tab-content p-3">
|
|
<div class="tab-pane fade show active" id="tab-system-main" role="tabpanel" aria-labelledby="tab-system-main">
|
|
@Html.Partial("_SystemMain")
|
|
</div>
|
|
|
|
<div class="tab-pane fade" id="tab-system-sub" role="tabpanel" aria-labelledby="tab-system-sub">
|
|
@Html.Partial("_SystemSub")
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
var systemMainTable, systemSubTable, deviceTable;
|
|
var selected_system_main_guid = "";
|
|
var selected_system_main_guid_top_name = "";
|
|
var selected_system_sub_guid = "";
|
|
var selected_system_device_item_guid = "";
|
|
//#region 系統大類 document ready
|
|
$(function () {
|
|
//#region 系統大類 DataTable
|
|
systemMainTable = $("#system_main_table").DataTable({
|
|
"columns": [
|
|
{
|
|
"data": null,
|
|
"render": function (data, type, row, meta) {
|
|
return meta.row + 1;
|
|
}
|
|
},
|
|
{
|
|
"data": "system_key"
|
|
},
|
|
{
|
|
"data": "system_value"
|
|
},
|
|
{
|
|
"data": "created_at"
|
|
},
|
|
{
|
|
"data": null,
|
|
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
|
|
}
|
|
],
|
|
'createdRow': function (row, data, dataIndex) {
|
|
$(row).attr('data-guid', data.id);
|
|
},
|
|
//"order": [[2, "desc"]],
|
|
"ajax": {
|
|
"url": "/SystemCategory/SystemMainList",
|
|
"type": "POST",
|
|
"dataSrc": function (rel) {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
return;
|
|
}
|
|
|
|
data = rel.data;
|
|
|
|
if (data == null || data.length == 0) {
|
|
this.data = [];
|
|
}
|
|
|
|
//系統小類上方選單
|
|
$("#system-main-list").empty();
|
|
$.each(data, function (key, value) {
|
|
if (key == 0) {
|
|
selected_system_main_guid_top_name = value.system_key;
|
|
$("#system-main-list").append(`<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.id}" onclick="clickSystemMain('${value.id}')">${value.system_key}</button>`);
|
|
$(`#${value.id}`).trigger("click");
|
|
}
|
|
else {
|
|
$("#system-main-list").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.id}" onclick="clickSystemMain('${value.id}')">${value.system_key}</button>`);
|
|
}
|
|
});
|
|
|
|
return data;
|
|
}
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 編輯系統大類
|
|
$('#system_main_table').on("click", "button.edit-btn", function () {
|
|
|
|
$("#system-main-modal .modal-title").html("系統大類資料 - 編輯");
|
|
|
|
selected_system_main_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
//取得單一系統大類
|
|
var url = "/SystemCategory/GetOneSystemMain";
|
|
|
|
var send_data = {
|
|
id: selected_system_main_guid
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
$("#system_main_name_modal").val(rel.data.system_key);
|
|
$("#system_main_code_modal").val(rel.data.system_value);
|
|
|
|
$("#system-main-modal").modal();
|
|
}
|
|
}, 'json');
|
|
|
|
});
|
|
//#endregion
|
|
|
|
//#region 刪除系統大類
|
|
$('#system_main_table').on("click", "button.del-btn", function () {
|
|
|
|
selected_system_main_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
Swal.fire(
|
|
{
|
|
title: "刪除",
|
|
text: "你確定是否刪除此筆資料?",
|
|
type: "warning",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: "是",
|
|
cancelButtonText: "否"
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
var url = "/SystemCategory/DeleteOneSystemMain";
|
|
var send_data = {
|
|
id: selected_system_main_guid
|
|
}
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
|
|
}
|
|
else if (rel.code == "9997") {
|
|
var htnl = rel.msg + "<br>" + rel.data
|
|
Swal.fire(
|
|
{
|
|
title: "刪除失敗",
|
|
icon: 'warning',
|
|
html: htnl,
|
|
});
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
systemMainTable.ajax.reload(null, false);
|
|
}
|
|
}, 'json');
|
|
}
|
|
});
|
|
});
|
|
//#endregion
|
|
});
|
|
//#endregion
|
|
|
|
//#region 新增系統大類資料
|
|
function AddSystemMain() {
|
|
selected_system_main_guid = "";
|
|
SystemMainValidate.resetForm();
|
|
$("#system-main-modal .modal-title").html("系統大類資料 - 新增");
|
|
$("#system-main-form").trigger("reset");
|
|
|
|
$("#system-main-modal").modal();
|
|
}
|
|
//#endregion
|
|
|
|
//#region 系統大類表單驗證
|
|
var SystemMainValidate = $("#system-main-form").validate({
|
|
rules: {
|
|
system_main_name_modal: {
|
|
required: true,
|
|
maxlength: 50,
|
|
filterspace: true
|
|
},
|
|
system_main_code_modal: {
|
|
required: true,
|
|
maxlength: 50,
|
|
filterspace: true
|
|
}
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 儲存系統大類資料
|
|
function SaveSystemMain() {
|
|
if ($("#system-main-form").valid()) {
|
|
|
|
$("#save-system-main-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
|
|
|
|
var url = "/SystemCategory/SaveSystemMain";
|
|
var send_data = {
|
|
id: selected_system_main_guid,
|
|
System_key: $('#system_main_name_modal').val(),
|
|
system_value : $('#system_main_code_modal').val()
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
$("#save-system-main-btn").html('確定').attr("disabled", false);
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
systemMainTable.ajax.reload(null, false);
|
|
$('#system-main-modal').modal('hide');
|
|
return;
|
|
}
|
|
}, 'json')
|
|
.fail(function (xhr, status, error) {
|
|
$("#save-system-main-btn").html('確定').attr("disabled", false);
|
|
});
|
|
}
|
|
}
|
|
//#endregion
|
|
</script>
|
|
|
|
<script>
|
|
//#region 系統小類 document ready
|
|
$(function () {
|
|
$('#submenucard').hide();
|
|
|
|
//#region 系統小類 DataTable
|
|
systemSubTable = $("#system_sub_table").DataTable({
|
|
"columns": [
|
|
{
|
|
"data": null,
|
|
"render": function (data, type, row, meta) {
|
|
return meta.row + 1;
|
|
}
|
|
},
|
|
{
|
|
"data": null,
|
|
"render": function (data, type, row, meta) {
|
|
return selected_system_main_guid_top_name;
|
|
}
|
|
},
|
|
{
|
|
"data": "system_key"
|
|
},
|
|
{
|
|
"data": "system_value"
|
|
},
|
|
{
|
|
"data": "created_at"
|
|
},
|
|
{
|
|
"data": null,
|
|
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
|
|
}
|
|
],
|
|
'createdRow': function (row, data, dataIndex) {
|
|
$(row).attr('data-guid', data.id);
|
|
},
|
|
//"order": [[2, "desc"]],
|
|
"ajax": {
|
|
"url": "/SystemCategory/SystemSubList",
|
|
"type": "POST",
|
|
"data": function (d) {
|
|
d.id = selected_system_main_guid
|
|
},
|
|
"dataSrc": function (rel) {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
return;
|
|
}
|
|
|
|
data = rel.data;
|
|
|
|
if (data == null || data.length == 0) {
|
|
this.data = [];
|
|
}
|
|
|
|
return data;
|
|
}
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 設備項目 DataTable
|
|
deviceTable = $("#device_sub_table").DataTable({
|
|
"columns": [
|
|
{
|
|
"data": null,
|
|
"render": function (data, type, row, meta) {
|
|
return meta.row + 1;
|
|
}
|
|
},
|
|
{
|
|
"data": "full_name"
|
|
},
|
|
{
|
|
"data": "points"
|
|
},
|
|
{
|
|
"data": "unit"
|
|
},
|
|
{
|
|
"data": "is_show"
|
|
},
|
|
{
|
|
"data": "is_show_riserDiagram"
|
|
},
|
|
{
|
|
"data": "is_controll"
|
|
},
|
|
{
|
|
"data": "is_bool"
|
|
},
|
|
{
|
|
"data": "is_link"
|
|
},
|
|
{
|
|
"data": null,
|
|
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
|
|
}
|
|
],
|
|
'createdRow': function (row, data, dataIndex) {
|
|
$(row).attr('data-guid', data.id);
|
|
},
|
|
//"order": [[2, "desc"]],
|
|
"ajax": {
|
|
"url": "/SystemCategory/DeviceItemTable",
|
|
"type": "POST",
|
|
"data": function (d) {
|
|
d.id = selected_system_sub_guid
|
|
},
|
|
"dataSrc": function (rel) {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
return;
|
|
}
|
|
|
|
data = rel.data;
|
|
|
|
if (data == null || data.length == 0) {
|
|
this.data = [];
|
|
}
|
|
|
|
$.each(data, function (index, rel) {
|
|
if (rel.is_show == 0) {
|
|
rel.is_show = "否"
|
|
} else {
|
|
rel.is_show = "是"
|
|
}
|
|
|
|
if (rel.is_show_riserDiagram == 0) {
|
|
rel.is_show_riserDiagram = "否"
|
|
} else {
|
|
rel.is_show_riserDiagram = "是"
|
|
}
|
|
|
|
if (rel.is_controll == 0) {
|
|
rel.is_controll = "否"
|
|
} else {
|
|
rel.is_controll = "是"
|
|
}
|
|
|
|
if (rel.is_bool == 0) {
|
|
rel.is_bool = "否"
|
|
} else {
|
|
rel.is_bool = "是"
|
|
}
|
|
|
|
if (rel.is_link == 0) {
|
|
rel.is_link = "否"
|
|
} else {
|
|
rel.is_link = "是"
|
|
}
|
|
});
|
|
|
|
return data;
|
|
}
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 編輯系統小類
|
|
$('#system_sub_table').on("click", "button.edit-btn", function () {
|
|
|
|
$("#system-sub-modal .modal-title").html("系統小類資料 - 編輯");
|
|
|
|
selected_system_sub_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
//取得單一系統小類
|
|
var url = "/SystemCategory/GetOneSystemSub";
|
|
|
|
var send_data = {
|
|
id: selected_system_sub_guid
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
$("#system_main_name").html(selected_system_main_guid_top_name)
|
|
$("#system_sub_name_modal").val(rel.data.system_key);
|
|
$("#system_sub_code_modal").val(rel.data.system_value);
|
|
|
|
$("#system-sub-modal").modal();
|
|
}
|
|
}, 'json');
|
|
|
|
});
|
|
//#endregion
|
|
|
|
//#region 刪除系統小類
|
|
$('#system_sub_table').on("click", "button.del-btn", function () {
|
|
|
|
selected_system_sub_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
Swal.fire(
|
|
{
|
|
title: "刪除",
|
|
text: "你確定是否刪除此筆資料?",
|
|
type: "warning",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: "是",
|
|
cancelButtonText: "否"
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
var url = "/SystemCategory/DeleteOneSystemSub";
|
|
var send_data = {
|
|
id: selected_system_sub_guid
|
|
}
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else if (rel.code == "9997") {
|
|
var htnl = rel.msg + "<br>" + rel.data
|
|
Swal.fire(
|
|
{
|
|
title: "刪除失敗",
|
|
icon: 'warning',
|
|
html: htnl,
|
|
});
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
$('#submenucard').hide();
|
|
systemSubTable.ajax.reload(null, false);
|
|
return;
|
|
}
|
|
}, 'json');
|
|
}
|
|
});
|
|
});
|
|
//#endregion
|
|
});
|
|
//#endregion
|
|
|
|
//#region 系統小類畫面 - 選擇系統大類
|
|
function clickSystemMain(guid) {
|
|
selected_system_main_guid = guid;
|
|
selected_system_main_guid_top_name = $(`#${guid}`).text();
|
|
|
|
if ($('#system-main-list').find('.btn-station').hasClass("btn-success")) {
|
|
$('#system-main-list').find('.btn-station').removeClass("btn-success").addClass("btn-outline-success");
|
|
}
|
|
$(`#${guid}`).removeClass("btn-outline-success").addClass("btn-success");
|
|
$('#submenucard').hide();
|
|
systemSubTable.ajax.reload(null, false);
|
|
}
|
|
//#endregion
|
|
|
|
//#region 新增系統小類資料
|
|
function AddSystemSub() {
|
|
selected_system_sub_guid = "";
|
|
SystemSubValidate.resetForm();
|
|
$("#system-sub-modal .modal-title").html("系統小類資料 - 新增");
|
|
$("#system-sub-form").trigger("reset");
|
|
|
|
$("#system_main_name").html(selected_system_main_guid_top_name)
|
|
|
|
$("#system-sub-modal").modal();
|
|
}
|
|
//#endregion
|
|
|
|
//#region 系統小類表單驗證
|
|
var SystemSubValidate = $("#system-sub-form").validate({
|
|
rules: {
|
|
system_sub_name_modal: {
|
|
required: true,
|
|
maxlength: 50,
|
|
filterspace: true
|
|
},
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 儲存系統小類資料
|
|
function SaveSystemSub() {
|
|
if ($("#system-sub-form").valid()) {
|
|
$("#save-system-sub-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
|
|
|
|
var url = "/SystemCategory/SaveSystemSub";
|
|
var send_data = {
|
|
id: selected_system_sub_guid,
|
|
system_parent_id: selected_system_main_guid,
|
|
system_key: $('#system_sub_name_modal').val(),
|
|
system_value: $('#system_sub_code_modal').val()
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
$("#save-system-sub-btn").html('確定').attr("disabled", false);
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
$('#submenucard').hide();
|
|
systemSubTable.ajax.reload(null, false);
|
|
$('#system-sub-modal').modal('hide');
|
|
return;
|
|
}
|
|
}, 'json')
|
|
.fail(function (xhr, status, error) {
|
|
$("#save-system-sub-btn").html('確定').attr("disabled", false);
|
|
});
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//#region 新增設備項目
|
|
function Adddevice_item() {
|
|
//SubDeviceItemValidate.resetForm();
|
|
selected_system_device_item_guid = "";
|
|
$("#device-sub-modal .modal-title").html("設備項目 - 新增");
|
|
$("#device-item-sub-form").trigger("reset");
|
|
$("#device-sub-modal").modal();
|
|
}
|
|
//#endregion
|
|
|
|
$('#system_sub_table').on("click", "tbody>tr", function () {
|
|
$(this).parents().find('tr').css('background-color', '#fff');
|
|
$(this).css('background-color', '#67B4AC');
|
|
selected_system_sub_guid = $(this).attr('data-guid');
|
|
deviceTable.ajax.reload();
|
|
$('#submenucard').show();
|
|
});
|
|
|
|
//#region 設備項目表單驗證
|
|
$("#device-item-sub-form").validate({
|
|
rules: {
|
|
device_sub_name_modal: {
|
|
required: true,
|
|
maxlength: 50
|
|
},
|
|
device_sub_points_modal: {
|
|
required: true,
|
|
maxlength: 20
|
|
}
|
|
}
|
|
});
|
|
//#endregion
|
|
|
|
//#region 儲存設備項目
|
|
function Savedevice_item() {
|
|
if ($("#device-item-sub-form").valid()) {
|
|
$("#save-device-item-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
|
|
|
|
var uurl = "/SystemCategory/HaveSamePoints";
|
|
var ssend_data = {
|
|
subId: selected_system_sub_guid,
|
|
id: selected_system_device_item_guid,
|
|
points: $('#device_sub_points_modal').val(),
|
|
}
|
|
$.post(uurl, ssend_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
if (rel.data) {
|
|
toast_warning("點位名稱已存在");
|
|
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
|
}
|
|
else {
|
|
var url = "/SystemCategory/Savedevice_item";
|
|
var send_data = {
|
|
id: selected_system_device_item_guid,
|
|
device_system_tag: selected_system_main_guid,
|
|
device_name_tag: selected_system_sub_guid,
|
|
full_name: $('#device_sub_name_modal').val(),
|
|
points: $('#device_sub_points_modal').val(),
|
|
unit: $('#device_sub_unit_modal').val(),
|
|
is_show: $('input[name="is_show"]:checked').val(),
|
|
is_show_riserDiagram: $('input[name="is_show_riserDiagram"]:checked').val(),
|
|
is_controll: $('input[name="is_controll"]:checked').val(),
|
|
is_bool: $('input[name="is_bool"]:checked').val(),
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
deviceTable.ajax.reload(null, false);
|
|
$('#device-sub-modal').modal('hide');
|
|
return;
|
|
}
|
|
}, 'json')
|
|
.fail(function (xhr, status, error) {
|
|
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
|
});
|
|
}
|
|
}
|
|
}, 'json')
|
|
.fail(function (xhr, status, error) {
|
|
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
|
});
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
//#region 編輯設備項目
|
|
$('#device_sub_table').on("click", "button.edit-btn", function () {
|
|
|
|
$("#device-sub-modal .modal-title").html("設備項目 - 編輯");
|
|
|
|
selected_system_device_item_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
//取得單一系統小類
|
|
var url = "/SystemCategory/GetOneDeviceItem";
|
|
|
|
var send_data = {
|
|
id: selected_system_device_item_guid
|
|
}
|
|
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
$("#device-item-sub-form").trigger("reset");
|
|
$("#device_sub_name_modal").val(rel.data.full_name);
|
|
$("#device_sub_points_modal").val(rel.data.points);
|
|
$("#device_sub_unit_modal").val(rel.data.unit);
|
|
$("input[name='is_show'][value='" + rel.data.is_show + "']").prop("checked", true);
|
|
$("input[name='is_show_riserDiagram'][value='" + rel.data.is_show_riserDiagram + "']").prop("checked", true);
|
|
$("input[name='is_controll'][value='" + rel.data.is_controll + "']").prop("checked", true);
|
|
$("input[name='is_bool'][value='" + rel.data.is_bool + "']").prop("checked", true);
|
|
$("input[name='is_link'][value='" + rel.data.is_link+ "']").prop("checked", true);
|
|
|
|
$("#device-sub-modal").modal();
|
|
}
|
|
}, 'json');
|
|
|
|
});
|
|
//#endregion
|
|
|
|
//#region 刪除設備項目
|
|
$('#device_sub_table').on("click", "button.del-btn", function () {
|
|
|
|
selected_system_device_item_guid = $(this).parents('tr').attr('data-guid');
|
|
|
|
Swal.fire(
|
|
{
|
|
title: "刪除",
|
|
text: "你確定是否刪除此筆資料?",
|
|
type: "warning",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: "是",
|
|
cancelButtonText: "否"
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
var uurl = "/SystemCategory/CheckCanDelete";
|
|
var ssend_data = {
|
|
subguid: selected_system_sub_guid,
|
|
guid: selected_system_device_item_guid
|
|
}
|
|
$.post(uurl, ssend_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
if (rel.data.delete) {
|
|
var htnl = "以下點位使用中,故無法刪除<br>" + rel.data.reason
|
|
Swal.fire(
|
|
{
|
|
title: "刪除失敗",
|
|
icon: 'warning',
|
|
html: htnl,
|
|
});
|
|
} else {
|
|
var url = "/SystemCategory/DeleteOneSystemSubDeviceItem";
|
|
var send_data = {
|
|
id: selected_system_device_item_guid
|
|
}
|
|
$.post(url, send_data, function (rel) {
|
|
if (rel.code != "0000") {
|
|
if (rel.code == "9999") {
|
|
toast_error(rel.msg);
|
|
}
|
|
else {
|
|
toast_warning(rel.msg);
|
|
}
|
|
return;
|
|
}
|
|
else {
|
|
toast_ok(rel.msg);
|
|
deviceTable.ajax.reload(null, false);
|
|
return;
|
|
}
|
|
|
|
}, 'json');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
//#endregion
|
|
|
|
</script>
|
|
} |