2022-11-22 12:09:35 +08:00
|
|
|
|
<main id="js-page-content" role="main" class="page-content">
|
2022-11-21 23:43:22 +08:00
|
|
|
|
|
2022-11-22 12:09:35 +08:00
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-sm-12 col-xl-12">
|
|
|
|
|
|
|
|
|
|
<h1 class="p-2 mb-0">圖資管理</h1>
|
2022-11-21 23:43:22 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-2">
|
2023-01-03 18:30:34 +08:00
|
|
|
|
<div class="row d-inline-block col-12 alert alert-secondary p-1 px-2 mb-0">
|
|
|
|
|
<span><i class="fas fa-exclamation-circle mr-2"></i>按右鍵即可展開選單</span>
|
|
|
|
|
</div>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div class="row d-inline-block col-12 p-0 my-2 text-center">
|
|
|
|
|
<input id="graCatSearch" name="graCatSearch" type="text" class="form-control form-control-sm d-inline-block" placeholder="搜尋" />
|
2022-11-21 23:43:22 +08:00
|
|
|
|
</div>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div class="d-flex" id="graTree"></div>
|
2022-11-21 23:43:22 +08:00
|
|
|
|
</div>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div class="col-10">
|
2023-01-04 18:49:37 +08:00
|
|
|
|
<div class="row my-2 mx-0">
|
2022-12-14 15:57:49 +08:00
|
|
|
|
<a href="javascript:;" id="creGraMan" class="btn btn-success">
|
|
|
|
|
+新增
|
2022-12-13 18:41:32 +08:00
|
|
|
|
</a>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
<label id="curLevText" class="ml-3 mb-0 row m-0 align-items-center fs-1"></label>
|
2022-11-21 23:43:22 +08:00
|
|
|
|
</div>
|
2022-11-22 12:09:35 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<table id="graTable" class="table table-bordered table-striped text-center m-0">
|
|
|
|
|
</table>
|
2022-11-21 23:43:22 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-11-22 12:09:35 +08:00
|
|
|
|
|
2022-11-21 23:43:22 +08:00
|
|
|
|
</div>
|
2022-11-22 12:09:35 +08:00
|
|
|
|
</div>
|
2022-11-21 23:43:22 +08:00
|
|
|
|
|
2022-11-22 12:09:35 +08:00
|
|
|
|
</main>
|
|
|
|
|
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<!-- upload modal -->
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div class="modal fade" id="graModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
|
|
|
|
|
data-keyboard="false">
|
2022-11-22 12:09:35 +08:00
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h4 class="modal-title">
|
2022-11-22 17:18:39 +08:00
|
|
|
|
圖資上傳
|
2022-11-22 12:09:35 +08:00
|
|
|
|
</h4>
|
|
|
|
|
</div>
|
2022-11-22 17:18:39 +08:00
|
|
|
|
<form id="uploadForm">
|
2022-11-21 23:43:22 +08:00
|
|
|
|
<div class="modal-body">
|
2022-11-22 12:09:35 +08:00
|
|
|
|
<div class="row">
|
2023-01-03 18:30:34 +08:00
|
|
|
|
<!--<div class="col-md-6">
|
2022-11-22 12:09:35 +08:00
|
|
|
|
<div class="form-group">
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<label class="form-label" for="upPicNum">圖號</label>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<input type="text" id="graPicNum" name="graPicNum" class="form-control">
|
2022-11-22 12:09:35 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-6">
|
|
|
|
|
<div class="form-group">
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<label class="form-label" for="upPicName">圖名</label>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<input type="text" id="graPicName" name="graPicName" class="form-control">
|
2022-11-22 12:09:35 +08:00
|
|
|
|
</div>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
</div>-->
|
|
|
|
|
<div class="col-md-6">
|
2022-11-24 12:05:23 +08:00
|
|
|
|
<div class="form-group">
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<label class="form-label" for="graSelMain">圖資類別</label>
|
|
|
|
|
<label id="graLayer" class="m-0 fs-1 col-12 p-0"></label>
|
2022-11-22 17:18:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
<div class="col-md-12 mt-2">
|
2023-01-04 18:49:37 +08:00
|
|
|
|
<label>檔案</label>
|
2022-11-22 18:09:04 +08:00
|
|
|
|
</div>
|
2022-11-22 17:18:39 +08:00
|
|
|
|
<div class="col-md-12">
|
2022-11-24 09:29:51 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div id="graMyDesignDiagram" class="dropzone">
|
|
|
|
|
<div class="dz-message">
|
|
|
|
|
<div class="drag-icon-cph">
|
|
|
|
|
<i class="material-icons">backup</i>
|
|
|
|
|
</div>
|
|
|
|
|
<h3>選擇一個文件或拖放到這裡</h3>
|
|
|
|
|
<p class="mb-0 col-grey">
|
2023-01-31 10:17:59 +08:00
|
|
|
|
(圖片檔, 文字檔, word, ppt, excel, pdf)檔案不超過 10MB
|
2022-12-13 18:41:32 +08:00
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fallback">
|
|
|
|
|
<input name="file" type="file" multiple />
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
<!--<div class="col-md-12 mt-3">
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<label>竣工圖</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-12">
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<div id="graMyAsBuilt" class="dropzone">
|
|
|
|
|
<div class="dz-message">
|
|
|
|
|
<div class="drag-icon-cph">
|
|
|
|
|
<i class="material-icons">backup</i>
|
|
|
|
|
</div>
|
|
|
|
|
<h3>選擇一個文件或拖放到這裡</h3>
|
|
|
|
|
<p class="mb-0 col-grey">
|
|
|
|
|
DWG檔案不超過 10MB
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fallback">
|
|
|
|
|
<input name="file" type="file" multiple />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
</div>-->
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
2022-12-13 18:41:32 +08:00
|
|
|
|
<button type="button" class="btn btn-primary" id="graSendBtn">儲存</button>
|
|
|
|
|
<button type="button" class="btn btn-secondary" id="close" data-dismiss="modal">取消</button>
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- delete modal -->
|
2022-12-08 10:35:01 +08:00
|
|
|
|
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
|
2022-12-13 18:41:32 +08:00
|
|
|
|
data-keyboard="false">
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
|
<div class="modal-content">
|
2022-12-14 15:57:49 +08:00
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h4 class="modal-title">
|
|
|
|
|
確認刪除
|
|
|
|
|
</h4>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body py-1">
|
|
|
|
|
<label>確認要刪除此筆圖資資料?</label>
|
|
|
|
|
</div>
|
2022-12-05 15:22:41 +08:00
|
|
|
|
<div class="modal-footer">
|
2022-12-14 15:57:49 +08:00
|
|
|
|
<button type="button" class="btn btn-primary" id="delGraManBtn">確定</button>
|
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
|
|
|
|
</div>
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
2023-01-03 18:30:34 +08:00
|
|
|
|
</div>
|
2022-12-05 15:22:41 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2022-11-24 09:29:51 +08:00
|
|
|
|
<script>
|
2022-12-13 18:41:32 +08:00
|
|
|
|
var graTable = null;
|
|
|
|
|
var curLayerId = null;
|
|
|
|
|
var uploader = {};
|
|
|
|
|
var uploadFiles = {};
|
2022-12-14 15:57:49 +08:00
|
|
|
|
var curActGraid = 0;
|
2022-12-14 17:34:13 +08:00
|
|
|
|
var cookies = new YourTeam.Utility.Cookie();
|
|
|
|
|
var token = cookies.get("JWT-Authorization");
|
2022-11-24 09:29:51 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
initList();
|
2022-12-13 18:41:32 +08:00
|
|
|
|
initDropzone();
|
|
|
|
|
getGraCatList(initTree);
|
2022-11-24 09:29:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
2022-12-05 15:22:41 +08:00
|
|
|
|
// 讀取列表資料
|
2022-11-24 09:29:51 +08:00
|
|
|
|
function initList() {
|
2022-12-13 18:41:32 +08:00
|
|
|
|
let ajaxObj = {
|
|
|
|
|
url: baseApiUrl + "/GraphManage/GraManList",
|
|
|
|
|
method: "POST",
|
|
|
|
|
data: {
|
|
|
|
|
layer_id: 0,
|
|
|
|
|
},
|
2022-11-24 09:29:51 +08:00
|
|
|
|
}
|
2022-12-13 18:41:32 +08:00
|
|
|
|
let tag = "#graTable";
|
|
|
|
|
|
|
|
|
|
let column_defs = [
|
2023-01-03 18:30:34 +08:00
|
|
|
|
{ "targets": [0], "width": "20%", "sortable": true },
|
|
|
|
|
{ "targets": [1], "width": "60%", "sortable": true },
|
|
|
|
|
{ "targets": [2], "width": "20%", "sortable": true },
|
2022-12-13 18:41:32 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let columns = [
|
|
|
|
|
{
|
2023-01-03 18:30:34 +08:00
|
|
|
|
"title": "編號",
|
|
|
|
|
"data": "id",
|
2022-12-14 09:54:29 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2023-01-03 18:30:34 +08:00
|
|
|
|
"title": "檔案",
|
2022-12-13 18:41:32 +08:00
|
|
|
|
"data": "oriOrgName",
|
|
|
|
|
"render": function (data, type, row, meta) {
|
2022-12-14 15:57:49 +08:00
|
|
|
|
return `<a id="oriDwgDown${row.id}" href="javascript:;">${row.oriOrgName ?? ""}</a>`;
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"title": "功能",
|
2022-12-14 10:53:28 +08:00
|
|
|
|
"data": "id",
|
2022-12-13 18:41:32 +08:00
|
|
|
|
"render": function (data, type, row, meta) {
|
|
|
|
|
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
|
|
|
|
|
btnDiv.append(creBtnHtml("修改", "graEdiBtn" + data, null, ["btn", "btn-info"]));
|
2022-12-14 15:57:49 +08:00
|
|
|
|
btnDiv.append(creBtnHtml("刪除", "graDelBtn" + data, null, ["btn", "btn-danger"]));
|
2022-12-13 18:41:32 +08:00
|
|
|
|
return btnDiv.outerHtml();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
graTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
|
2022-11-24 09:29:51 +08:00
|
|
|
|
}
|
2022-11-24 12:05:23 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
function initDropzone() {
|
|
|
|
|
Dropzone.autoDiscover = false;
|
|
|
|
|
let option = {
|
|
|
|
|
url: "/",
|
|
|
|
|
addRemoveLinks: true,
|
|
|
|
|
dictRemoveFile: `<span class="material-icons mi-delete">delete</span>`,
|
|
|
|
|
dictInvalidFileType: `上傳格式錯誤`,
|
|
|
|
|
dictCancelUploadConfirmation: `確定要取消上傳此檔案嗎?`,
|
|
|
|
|
dictCancelUpload: `<span class="material-icons mi-cancel">cancel</span>`,
|
2022-12-14 15:57:49 +08:00
|
|
|
|
dictMaxFilesExceeded: "已超過上傳限制數量",
|
2023-01-31 10:17:59 +08:00
|
|
|
|
dictFileTooBig:"已超出上傳限制,最大{{maxFilesize}}MB,而您的檔案{{filesize}}MB。",
|
2022-12-14 15:57:49 +08:00
|
|
|
|
maxFilesize: 10,
|
2022-12-13 18:41:32 +08:00
|
|
|
|
filesizeBase: 1024,
|
|
|
|
|
maxFiles: 1,
|
|
|
|
|
autoProcessQueue: false,
|
2023-01-31 10:17:59 +08:00
|
|
|
|
acceptedFiles: ".dwg,.jpeg,.jpg,.png,.gif,.doc,.docx,.ppt,.pptx,.xlsx,.xls,.opt,.pdf,.txt",
|
2022-12-13 18:41:32 +08:00
|
|
|
|
init: function () {
|
|
|
|
|
this.on("addedfile", function (file) {
|
2022-12-14 15:57:49 +08:00
|
|
|
|
$(this.previewsContainer).find('.dz-progress').addClass('d-none');
|
|
|
|
|
if (file.savename) {
|
|
|
|
|
file.accepted = true;
|
|
|
|
|
this.files.push(file);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.on("complete", function (file) {
|
|
|
|
|
if (file.savename) {
|
|
|
|
|
$(file.previewElement).find('.dz-image img').remove();
|
|
|
|
|
}
|
2022-12-13 18:41:32 +08:00
|
|
|
|
});
|
2022-12-14 15:57:49 +08:00
|
|
|
|
this.on("thumbnail", function (file) {
|
|
|
|
|
// 若為讀取檔案時
|
|
|
|
|
if (file.savename) {
|
|
|
|
|
$(file.previewElement).removeClass("dz-image-preview").addClass("dz-file-preview");
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uploader.graMyDesignDiagram = $("#graMyDesignDiagram").dropzone(option);
|
2022-12-14 09:54:29 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
uploader["graMyDesignDiagram"][0].dropzone.on("addedfile", file => {
|
|
|
|
|
uploadFiles["graMyDesignDiagram"] = file;
|
|
|
|
|
})
|
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
uploader["graMyDesignDiagram"][0].dropzone.on("removedfile", file => {
|
|
|
|
|
uploadFiles["graMyDesignDiagram"] = {};
|
|
|
|
|
file.previewElement.remove();
|
|
|
|
|
})
|
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
2022-12-07 15:45:41 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
// 新增資料
|
|
|
|
|
onEvent('click', '#graSendBtn', function () {
|
2022-12-14 15:57:49 +08:00
|
|
|
|
saveGraMan();
|
2022-12-05 15:22:41 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-12-14 10:53:28 +08:00
|
|
|
|
onEvent("click", "button[id^=graEdiBtn]", function () {
|
|
|
|
|
let id = $(this).prop("id").split("graEdiBtn")[1];
|
2022-12-14 15:57:49 +08:00
|
|
|
|
curActGraid = parseInt(id);
|
2022-12-14 10:53:28 +08:00
|
|
|
|
readGraph(id);
|
|
|
|
|
})
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent("click", "button[id^=graDelBtn]", function () {
|
|
|
|
|
let id = $(this).prop("id").split("graDelBtn")[1];
|
|
|
|
|
curActGraid = parseInt(id);
|
|
|
|
|
$("#delModal").modal("show");
|
|
|
|
|
})
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent("click", "a[id^=oriDwgDown]", function () {
|
2022-12-14 18:27:51 +08:00
|
|
|
|
let dowLoaEle = YT.Alert.Tip("準備下載中...", "show", true);
|
2022-12-14 15:57:49 +08:00
|
|
|
|
let rowData = graTable.row($(this).closest("tr")).data();
|
|
|
|
|
let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.oriSavName}&oriname=${rowData.oriOrgName}`;
|
2023-01-04 18:49:37 +08:00
|
|
|
|
|
|
|
|
|
download(token, apiUrl, rowData.oriOrgName, function () {
|
2022-12-14 18:27:51 +08:00
|
|
|
|
$(dowLoaEle.ele).YTAlert().hide();
|
2022-12-14 17:34:13 +08:00
|
|
|
|
});
|
2022-12-14 15:57:49 +08:00
|
|
|
|
})
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent("click", "a[id^=donDwgDown]", function () {
|
2022-12-14 18:27:51 +08:00
|
|
|
|
let dowLoaEle = YT.Alert.Tip("準備下載中...", "show", true);
|
2022-12-14 15:57:49 +08:00
|
|
|
|
let rowData = graTable.row($(this).closest("tr")).data();
|
|
|
|
|
let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.donSavName}&oriname=${rowData.donOrgName}`;
|
2023-01-31 10:17:59 +08:00
|
|
|
|
let extname = rowData.donOrgName?.split(".").slice(-1);
|
2022-12-14 17:34:13 +08:00
|
|
|
|
download(token, apiUrl, rowData.name + "_竣工圖" + "." + extname, function () {
|
2022-12-14 18:27:51 +08:00
|
|
|
|
$(dowLoaEle.ele).YTAlert().hide();
|
2022-12-14 17:34:13 +08:00
|
|
|
|
});
|
2022-12-14 15:57:49 +08:00
|
|
|
|
})
|
2022-12-14 10:53:28 +08:00
|
|
|
|
|
2022-12-07 09:07:59 +08:00
|
|
|
|
// 上傳檔案
|
2022-12-13 18:41:32 +08:00
|
|
|
|
var oriImg;
|
2022-12-05 15:22:41 +08:00
|
|
|
|
$("#upMyDesignDiagram").on("change", function (e) {
|
2022-11-24 12:05:23 +08:00
|
|
|
|
let fileHelper = new YourTeam.Utility.File();
|
2022-12-07 15:45:41 +08:00
|
|
|
|
oriImg = this.files[0];
|
2022-12-07 09:07:59 +08:00
|
|
|
|
fileHelper.readAndPreviewImages(this.files, 'upForDesignDiagram', 0, 86, '<div class="file-item">', '<button class="del-small-trash" name="btnDelImg" ><i class="fa fa-times"></i></button></div>');
|
2022-11-24 14:47:44 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
var donImg;
|
2022-12-07 15:45:41 +08:00
|
|
|
|
$("#upMyAsBuilt").on("change", function (e) {
|
|
|
|
|
let fileHelper = new YourTeam.Utility.File();
|
|
|
|
|
donImg = this.files[0];
|
|
|
|
|
fileHelper.readAndPreviewImages(this.files, 'upForAsBuilt', 0, 86, '<div class="file-item">', '<button class="del-small-trash" name="btnDelImg" ><i class="fa fa-times"></i></button></div>');
|
|
|
|
|
});
|
2022-11-24 14:47:44 +08:00
|
|
|
|
|
2022-12-07 09:07:59 +08:00
|
|
|
|
// 關閉 modal
|
|
|
|
|
$('#uploadPicture').on('hidden.bs.modal', function (e) {
|
|
|
|
|
console.log("123456789");
|
|
|
|
|
});
|
|
|
|
|
$('#colorModal').on('hidden.bs.modal', function () {
|
|
|
|
|
// # 可以设置下拉框为初始值
|
|
|
|
|
$("#colorCodeSelect").val(-1);
|
|
|
|
|
// # 清空表单校验信息
|
|
|
|
|
$("#add").Validform().resetForm();
|
|
|
|
|
$(".Validform_checktip").html("");
|
|
|
|
|
});
|
|
|
|
|
|
2022-12-05 15:22:41 +08:00
|
|
|
|
// 刪除資料
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent("click", "#delGraManBtn", function () {
|
|
|
|
|
delGraMan();
|
|
|
|
|
})
|
2022-12-05 15:22:41 +08:00
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent('click', '#creGraMan', function () {
|
|
|
|
|
curActGraid = 0;
|
|
|
|
|
$("#graModal").modal("show");
|
2022-12-05 15:22:41 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
onEvent('show.bs.modal', "#graModal", function (e) {
|
|
|
|
|
let type = $(e.relatedTarget).data("type");
|
|
|
|
|
$(this).data("type", type);
|
|
|
|
|
$("#graPicNum").val("");
|
|
|
|
|
$("#graPicName").val("");
|
|
|
|
|
uploadFiles["graMyDesignDiagram"] = {};
|
2023-01-03 18:30:34 +08:00
|
|
|
|
/*uploadFiles["graMyAsBuilt"] = {};*/
|
2022-12-14 15:57:49 +08:00
|
|
|
|
uploader["graMyDesignDiagram"][0].dropzone.removeAllFiles(true);
|
|
|
|
|
$("#graMyDesignDiagram .dz-preview").remove();
|
2023-01-03 18:30:34 +08:00
|
|
|
|
//uploader["graMyAsBuilt"][0].dropzone.removeAllFiles(true);
|
|
|
|
|
//$("#graMyAsBuilt .dz-preview").remove();
|
2022-12-14 15:57:49 +08:00
|
|
|
|
})
|
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
function getGraCatList(callback) {
|
|
|
|
|
let url = baseApiUrl + "/GraphManage/VarList";
|
|
|
|
|
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, null, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
res.data.forEach(x => x.parent = x.system_parent_id);
|
|
|
|
|
res.data.forEach(x => x.text = x.system_key);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
res.data.forEach(x => x.parent = x.parent);
|
2022-12-13 18:41:32 +08:00
|
|
|
|
callback ? callback(res.data) : "";
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initTree(data) {
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
treeEvent();
|
|
|
|
|
let option = {
|
|
|
|
|
core: {
|
2022-12-14 09:54:29 +08:00
|
|
|
|
"check_callback": true,
|
2023-01-03 18:30:34 +08:00
|
|
|
|
data: setTreeData(data),
|
2022-12-13 18:41:32 +08:00
|
|
|
|
themes: {
|
|
|
|
|
name: "default-dark"
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
types: {
|
|
|
|
|
default: {
|
|
|
|
|
max_depth: 3,
|
|
|
|
|
icon: "fas fa-folder text-warning"
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-12-14 09:54:29 +08:00
|
|
|
|
plugins: ["themes", "contextmenu", "sort", "conditionalselect", "search", "types"],
|
2022-12-13 18:41:32 +08:00
|
|
|
|
|
|
|
|
|
search: {
|
|
|
|
|
case_insensitive: true,
|
|
|
|
|
show_only_matches: true,
|
|
|
|
|
},
|
|
|
|
|
contextmenu: {
|
|
|
|
|
items: function ($node) {
|
|
|
|
|
let tree = this;
|
|
|
|
|
let depth = $node.parents.length; //抓出該節點深度(第幾層)
|
|
|
|
|
return {
|
|
|
|
|
Create: {
|
|
|
|
|
label: "新增",
|
|
|
|
|
_disabled: function (data) {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
if (depth >= 4) {
|
|
|
|
|
return true; //第三層後無法新增
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
2022-12-14 09:54:29 +08:00
|
|
|
|
return false;
|
2022-12-13 18:41:32 +08:00
|
|
|
|
},
|
|
|
|
|
action: function (obj) {
|
|
|
|
|
$node = tree.create_node($node, { text: '新類別', type: 'default' });
|
|
|
|
|
tree.deselect_all();
|
|
|
|
|
tree.select_node($node);
|
|
|
|
|
tree.edit($node);
|
2022-12-14 09:54:29 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Rename: {
|
|
|
|
|
label: "重新命名",
|
2023-01-04 18:49:37 +08:00
|
|
|
|
_disabled: function (data) {
|
|
|
|
|
if ($node.id == "0") {
|
|
|
|
|
return true; //最上層無法編輯
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2022-12-13 18:41:32 +08:00
|
|
|
|
action: function (obj) {
|
|
|
|
|
tree.edit($node);
|
|
|
|
|
/* tree.sort($node, true)*/
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Remove: {
|
|
|
|
|
label: "移除",
|
2023-01-04 18:49:37 +08:00
|
|
|
|
_disabled: function (data) {
|
|
|
|
|
if ($node.id == "0") {
|
|
|
|
|
return true; //最上層無法移除
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2022-12-13 18:41:32 +08:00
|
|
|
|
action: function (obj) {
|
|
|
|
|
tree.delete_node($node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$("#graTree").jstree(option);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function treeEvent() {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
let selectedNode = [];
|
2022-12-13 18:41:32 +08:00
|
|
|
|
$('#graTree').on("loaded.jstree", function (e, data) {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
let topNode = $('#graTree').jstree(true).get_node("0");
|
2022-12-13 18:41:32 +08:00
|
|
|
|
$('#graTree').jstree(true).select_node(topNode.children[0]);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
$("#graTree").jstree("open_node", 0);
|
2022-12-13 18:41:32 +08:00
|
|
|
|
})
|
|
|
|
|
$('#graTree').on("select_node.jstree", function (e, data) {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
if (data.node.id != "0") {
|
|
|
|
|
dtAjaxResetSendData(graTable, { layer_id: parseInt(data.node.id) });
|
|
|
|
|
graTable.ajax.reload();
|
|
|
|
|
selectedNode.unshift(data.node.id);
|
|
|
|
|
if (selectedNode.length > 3) {
|
|
|
|
|
selectedNode.splice(selectedNode.length - 1, 1);
|
|
|
|
|
}
|
|
|
|
|
curLayerId = parseInt(data.node.id);
|
|
|
|
|
$("#graLayer").text(levelNameByNodeId(data.node));
|
|
|
|
|
$("#curLevText").text(levelNameByNodeId(data.node));
|
|
|
|
|
} else {
|
|
|
|
|
$("#graTree").jstree(true).deselect_node(data.node);
|
|
|
|
|
$("#graTree").jstree(true).select_node(selectedNode[0]);
|
|
|
|
|
}
|
2022-12-13 18:41:32 +08:00
|
|
|
|
})
|
|
|
|
|
$("#graTree").on('create_node.jstree', function (e, data) {
|
|
|
|
|
let main = {};
|
|
|
|
|
main.system_key = data.node.text;
|
|
|
|
|
main.system_parent_id = parseInt(data.node.parent);
|
|
|
|
|
|
|
|
|
|
objSendData.Data = main;
|
|
|
|
|
|
|
|
|
|
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveVar", objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000") {
|
2022-12-14 09:54:29 +08:00
|
|
|
|
data.instance.delete_node(data.node);
|
|
|
|
|
toast_error(res.msg || common.SysErr);
|
2022-12-13 18:41:32 +08:00
|
|
|
|
} else {
|
|
|
|
|
data.instance.set_id(data.node, res.data);
|
2022-12-14 15:57:49 +08:00
|
|
|
|
|
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
$("#graTree").on('rename_node.jstree', function (e, data) {
|
|
|
|
|
let main = {}
|
2022-12-14 15:57:49 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
main.id = parseInt(data.node.id);
|
|
|
|
|
main.system_key = data.node.text;
|
|
|
|
|
|
|
|
|
|
objSendData.Data = main;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditVar", objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
2022-12-14 09:54:29 +08:00
|
|
|
|
toast_error(res.msg || common.SysErr);
|
2022-12-13 18:41:32 +08:00
|
|
|
|
} else {
|
|
|
|
|
getGraCatList((graCatData) => {
|
2023-01-03 18:30:34 +08:00
|
|
|
|
data.instance.settings.core.data = setTreeData(graCatData);
|
2022-12-13 18:41:32 +08:00
|
|
|
|
data.instance.refresh(true);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
$("#graTree").on('delete_node.jstree', function (e, data) {
|
|
|
|
|
let main = {};
|
2022-12-14 09:54:29 +08:00
|
|
|
|
if (!isNaN(parseInt(data.node.id))) {
|
|
|
|
|
main.id = parseInt(data.node.id);
|
|
|
|
|
objSendData.Data = main;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelVar", objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
toast_error(res.msg || common.SysErr);
|
|
|
|
|
} else {
|
|
|
|
|
getGraCatList((graCatData) => {
|
|
|
|
|
data.settings.core.data = graCatData;
|
|
|
|
|
data.instance.refresh(true);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
}
|
2022-12-13 18:41:32 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onEvent("keyup", "#graCatSearch", function () {
|
|
|
|
|
$("#graTree").jstree("search", $(this).val());
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 18:30:34 +08:00
|
|
|
|
function setTreeData(dataList) {
|
|
|
|
|
let parent = { parent: "#", text: "圖資管理", id: 0 };
|
|
|
|
|
dataList.push(parent);
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 10:53:28 +08:00
|
|
|
|
function readGraph(id) {
|
2022-12-13 18:41:32 +08:00
|
|
|
|
let url = baseApiUrl + "/GraphManage/GraManRead";
|
2022-12-14 10:53:28 +08:00
|
|
|
|
objSendData.Data = { id: parseInt(id) };
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
2022-12-13 18:41:32 +08:00
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
2023-01-03 18:30:34 +08:00
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
$("#graModal").modal("show");
|
|
|
|
|
|
|
|
|
|
let fileObj = {};
|
|
|
|
|
$("#graPicNum").val(res.data?.code);
|
|
|
|
|
$("#graPicName").val(res.data?.name);
|
2022-12-14 10:53:28 +08:00
|
|
|
|
$("#graLayer").text(levelNameByNodeId(res.data?.layer_id));
|
2022-12-14 15:57:49 +08:00
|
|
|
|
if (res.data?.oriSavName != null) {
|
2023-01-03 18:30:34 +08:00
|
|
|
|
fileObj = { name: res.data?.oriOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.oriSavName, savename: res.data?.oriSavName, size: res.data?.oriSize };
|
2022-12-14 15:57:49 +08:00
|
|
|
|
uploader["graMyDesignDiagram"][0].dropzone?.displayExistingFile(fileObj);
|
|
|
|
|
}
|
2023-01-03 18:30:34 +08:00
|
|
|
|
//if (res.data?.donSavName != null) {
|
|
|
|
|
// fileObj = { name: res.data?.donOrgName, dataUrl: baseApiUrl + varGraPath + res.data?.donSavName, savename: res.data?.donSavName, size: res.data?.donSize };
|
|
|
|
|
// uploader["graMyAsBuilt"][0].dropzone?.displayExistingFile(fileObj);
|
|
|
|
|
//}
|
2022-12-14 10:53:28 +08:00
|
|
|
|
|
2022-12-13 18:41:32 +08:00
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 10:53:28 +08:00
|
|
|
|
function levelNameByNodeId(node) {
|
|
|
|
|
let names = [];
|
|
|
|
|
let curNode = $('#graTree').jstree(true).get_node(node);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
let parents = curNode.parents.reverse();
|
2023-01-04 18:49:37 +08:00
|
|
|
|
|
2023-01-03 18:30:34 +08:00
|
|
|
|
for (let i = parents.length - 1; i >= 0; i--) {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
if (parents[i] != "#") {
|
2023-01-03 18:30:34 +08:00
|
|
|
|
let node = $('#graTree').jstree(true).get_node(parents[i]);
|
2022-12-14 10:53:28 +08:00
|
|
|
|
names.push(node.text);
|
|
|
|
|
}
|
2023-01-03 18:30:34 +08:00
|
|
|
|
}
|
2023-01-04 18:49:37 +08:00
|
|
|
|
|
2022-12-14 10:53:28 +08:00
|
|
|
|
names.push(curNode.text);
|
|
|
|
|
return names.join("/");
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-14 15:57:49 +08:00
|
|
|
|
|
|
|
|
|
function saveGraMan() {
|
|
|
|
|
let cookies = new YourTeam.Utility.Cookie();
|
|
|
|
|
let url = "";
|
|
|
|
|
let graMyDesDiaFile = uploader["graMyDesignDiagram"][0].dropzone.files.filter(x => x.accepted == true)[0];
|
2023-01-03 18:30:34 +08:00
|
|
|
|
/*let graMyAsBuiFile = uploader["graMyAsBuilt"][0].dropzone.files.filter(x => x.accepted == true)[0];*/
|
2022-12-14 15:57:49 +08:00
|
|
|
|
let fd = new FormData();
|
|
|
|
|
fd.append("layer_id", curLayerId);
|
|
|
|
|
fd.append("oriOrgName", graMyDesDiaFile?.name ?? null);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
/*fd.append("donOrgName", graMyAsBuiFile?.name ?? null);*/
|
2022-12-14 15:57:49 +08:00
|
|
|
|
fd.append("oriSavName", graMyDesDiaFile?.savename ?? null);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
/*fd.append("donSavName", graMyAsBuiFile?.savename ?? null);*/
|
2022-12-14 15:57:49 +08:00
|
|
|
|
fd.append("oriFile", graMyDesDiaFile?.savename ? null : graMyDesDiaFile ?? null);
|
2023-01-03 18:30:34 +08:00
|
|
|
|
/*fd.append("donFile", graMyAsBuiFile?.savename ? null : graMyAsBuiFile ?? null);*/
|
|
|
|
|
|
2022-12-14 15:57:49 +08:00
|
|
|
|
if (curActGraid == 0) {
|
|
|
|
|
url = baseApiUrl + "/GraphManage/SaveGraMan";
|
|
|
|
|
} else {
|
|
|
|
|
fd.append("id", curActGraid);
|
|
|
|
|
url = baseApiUrl + "/GraphManage/EdtOneGraMan";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: fd,
|
|
|
|
|
async: false,
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
processData: false,
|
|
|
|
|
beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', "Bearer " + cookies.get("JWT-Authorization")) },
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
} else {
|
|
|
|
|
$("#graModal").modal("hide");
|
|
|
|
|
toast_ok(curActGraid == 0 ? common.AddSuc : common.EditSuc);
|
|
|
|
|
graTable.ajax.reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delGraMan() {
|
|
|
|
|
if (curActGraid != 0) {
|
|
|
|
|
let url = baseApiUrl + "/GraphManage/DelOneGraMan";
|
|
|
|
|
objSendData.Data = { id: curActGraid };
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$("#delModal").modal("hide");
|
|
|
|
|
toast_ok(common.DelSuc);
|
|
|
|
|
graTable.ajax.reload();
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
2023-01-03 18:30:34 +08:00
|
|
|
|
}
|
2022-12-14 15:57:49 +08:00
|
|
|
|
}
|
2022-11-24 09:29:51 +08:00
|
|
|
|
</script>
|