|
|
@@ -83,7 +83,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
<form id="uploadForm">
|
|
|
<div class="row">
|
|
|
<div class="col-sm-6">
|
|
|
- <div class="form-group">
|
|
|
+ <div class="form-group" id="APIName-Form">
|
|
|
<label class="control-label">API名稱</label>
|
|
|
<input required="required" type="text" id="APIName" name="APIName" class="form-control">
|
|
|
</div>
|
|
|
@@ -371,11 +371,14 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
</section>
|
|
|
<script>
|
|
|
/*Vue */
|
|
|
+ var isDuplicate = false;
|
|
|
vm.mount('.body');
|
|
|
addUserImage(userName.charAt(0), role);
|
|
|
const revit = ['通用', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023'];
|
|
|
- const dynamo = ['1.3','2.0', '2.1', '2.2', '2.3','2.13'];
|
|
|
+ const dynamo = ['1.3', '2.0', '2.1', '2.2', '2.3', '2.13'];
|
|
|
$(document).ready(function() {
|
|
|
+ $("#source").val(userName);
|
|
|
+
|
|
|
$("#software").on('change', function(event) {
|
|
|
$("#version").empty();
|
|
|
switch (event.currentTarget.value) {
|
|
|
@@ -402,21 +405,37 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ $("#APIName").on('change', function() {
|
|
|
+ console.log($(this).val())
|
|
|
+ isDuplicate = checkDuplicate($(this).val())
|
|
|
+ if (isDuplicate) {
|
|
|
+ $("#APIName-Form").append(`<label id="APIName-label" class="error">此API已經匯入過</label>`);
|
|
|
+ $("#APIName-Form").addClass("has-error");
|
|
|
+ } else {
|
|
|
+ $("#APIName-label").remove();
|
|
|
+ $("#APIName-Form").attr("class","form-group");
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
$("#uploadForm").submit(function(e) {
|
|
|
e.preventDefault();
|
|
|
|
|
|
+ if (isDuplicate) {
|
|
|
+ alert('尚未提供上傳不同版本功能,請勿重複上傳!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
if ($("#files").val() === "") {
|
|
|
- alert('請選擇上傳檔案');
|
|
|
+ alert('請先選擇上傳檔案!');
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
var formData = new FormData();
|
|
|
$(".form-control").each(function(ele) {
|
|
|
- formData.append($(this).attr('name'),$(this).val());
|
|
|
+ formData.append($(this).attr('name'), $(this).val());
|
|
|
})
|
|
|
for (i = 0; i < $("#files").prop('files').length; i++) {
|
|
|
formData.append("files[]", $("#files").prop('files')[i]);
|
|
|
- //image_number++;
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
@@ -448,6 +467,28 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ function checkDuplicate(APIName) {
|
|
|
+ var isDuplicate = false;
|
|
|
+ $.ajax({
|
|
|
+ url: "./script/php/get_api_duplicate.php",
|
|
|
+ type: "POST",
|
|
|
+ data: {
|
|
|
+ APIName: APIName,
|
|
|
+ },
|
|
|
+ async: false,
|
|
|
+ dataType: "json"
|
|
|
+ }).done(function(result) {
|
|
|
+
|
|
|
+ if (result != "") {
|
|
|
+ isDuplicate = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }).error(function(error) {
|
|
|
+ console.log(error);
|
|
|
+ });
|
|
|
+ return isDuplicate;
|
|
|
+ }
|
|
|
</script>
|
|
|
<?php include("bim-support-body.html"); ?>
|
|
|
|