You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
203 lines
8.9 KiB
203 lines
8.9 KiB
@section('css') |
|
@parent |
|
<style> |
|
.modal-xl { |
|
max-width: 1140px; |
|
} |
|
</style> |
|
@stop |
|
|
|
@section('js') |
|
@parent |
|
<script> |
|
function EquipmentCreatePopUp(id) { |
|
lastModal = 'equipmentCreatePopUp' |
|
document.getElementById("equipmentCreate").reset(); |
|
// reloadUnit() |
|
$("#equipmentCreatePopUp").modal("show"); |
|
} |
|
|
|
function storeEquipment() { |
|
// Get form data |
|
let formData = $("#equipmentCreate").serialize(); |
|
// 如果必填選項沒有填選 |
|
if ($('#start_num').val() == '' || $('#end_num').val() == '' || $('#outlaw_speed').val() == '' || $('#location_name').val() == '' |
|
|| $('#distance').val() == '' || $('#limit_speed').val() == '' || $('#location_id').val() == '' |
|
|| $('#start_cert').val() == '' || $('#end_cert').val() == '') { |
|
Swal.fire({ |
|
icon: 'error', |
|
title: '錯誤', |
|
text: '請填寫必填欄位' |
|
}); |
|
return |
|
} |
|
// 起始機號與結束機號不可相同 |
|
if ($('#start_num').val() == $('#end_num').val()) { |
|
Swal.fire({ |
|
icon: 'error', |
|
title: '錯誤', |
|
text: '起始機號與結束機號不可相同' |
|
}); |
|
return |
|
} |
|
// 起始日不可大於結束日 |
|
if ($('#start_cert').val() > $('#end_cert').val()) { |
|
Swal.fire({ |
|
icon: 'error', |
|
title: '錯誤', |
|
text: '證書起始日不可大於證書到期日' |
|
}); |
|
return |
|
} |
|
// Perform Ajax request |
|
$.ajax({ |
|
url: `/api/itl/road`, // Replace with your actual endpoint |
|
type: "POST", |
|
data: formData, |
|
success: function(response) { |
|
// Check response and show appropriate message |
|
if (response.success) { |
|
// Show success alert |
|
Swal.fire({ |
|
icon: 'success', |
|
title: '成功', |
|
text: response.message |
|
}); |
|
// Close the modal |
|
$("#equipmentCreatePopUp").modal("hide"); |
|
equipmentTable.ajax.reload(null, false); |
|
} else { |
|
// Show error alert with the error message |
|
Swal.fire({ |
|
icon: 'error', |
|
title: '錯誤', |
|
text: response.message |
|
}); |
|
} |
|
}, |
|
error: function(xhr, status, error) { |
|
// Show error alert with the error details |
|
Swal.fire({ |
|
icon: 'error', |
|
title: '錯誤', |
|
text: '錯誤,請檢查後再試.' |
|
}); |
|
} |
|
}); |
|
} |
|
// assetownership_id on change |
|
$('#assetownership_id_create').on('change', function() { |
|
// console.log($(this).val()) |
|
if ($(this).val() == 'create') { |
|
unitPopUp('assetownership') |
|
$(this).val('') |
|
} |
|
}) |
|
|
|
// custodyunit_id on change |
|
$('#custodyunit_id_create').on('change', function() { |
|
if ($(this).val() == 'create') { |
|
unitPopUp('custodyunit') |
|
$(this).val('') |
|
} |
|
}) |
|
</script> |
|
|
|
@endsection |
|
<!-- Modal --> |
|
|
|
<div class="modal fade" id="equipmentCreatePopUp" tabindex="-1" aria-labelledby="equipmentCreatePopUpLabel" |
|
aria-modal="true" role="dialog"> |
|
<div class="modal-dialog modal-xl"> |
|
<div class="modal-content"> |
|
<div class="modal-header"> |
|
<h5 class="modal-title h4" id="equipmentCreatePopUpLabel">設備管理<small>(紅色星號必填)</small></h5> |
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
|
</div> |
|
<div class="modal-body"> |
|
<form id="equipmentCreate" class="row"> |
|
|
|
<!-- Your form fields here --> |
|
<div class="form-group col-3"> |
|
<label for="start_num">入口處編號<span class="text-danger">*</span></label> |
|
<select class="form-select" id="start_num" name="start_num"> |
|
<option value="">請選擇</option> |
|
@if (isset($location)) |
|
@foreach ($location as $item) |
|
<option value="{{ $item->id }}">[{{ $item->serialnumber }}] {{ $item->location }}</option> |
|
@endforeach |
|
@endif |
|
</select> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="end_num">出口處編號<span class="text-danger">*</span></label> |
|
<select class="form-select" id="end_num" name="end_num"> |
|
<option value="">請選擇</option> |
|
@if (isset($location)) |
|
@foreach ($location as $item) |
|
<option value="{{ $item->id }}">[{{ $item->serialnumber }}] {{ $item->location }}</option> |
|
@endforeach |
|
@endif |
|
</select> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="location_name">路段名稱<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="location_name" name="location"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="distance">距離<span class="text-danger">*</span></label> |
|
<input type="number" class="form-control" id="distance" name="distance"> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="limit_speed">限速<span class="text-danger">*</span></label> |
|
<input type="number" class="form-control" id="limit_speed" name="limit_speed"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="outlaw_speed">取締限速<span class="text-danger">*</span></label> |
|
<input type="number" class="form-control" id="outlaw_speed" name="outlaw_speed"> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="count_alert">違規數異常警示</label> |
|
<input type="number" class="form-control" id="count_alert" name="count_alert"> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="speed_alert">超速異常警示</label> |
|
<input type="number" class="form-control" id="speed_alert" name="speed_alert"> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="location_id">地點代碼<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="location_id" name="location_id"> |
|
</div> |
|
|
|
<div class="form-group col-3"> |
|
<label for="cert">合格證書<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="cert" name="certificatenumber"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="start_cert">證書起始日<span class="text-danger">*</span></label> |
|
<input type="date" class="form-control" id="start_cert" name="start_cert"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="end_cert">證書到期日<span class="text-danger">*</span></label> |
|
<input type="date" class="form-control" id="end_cert" name="end_cert"> |
|
</div> |
|
|
|
|
|
|
|
<div class="form-group col-12 text-center mt-3"> |
|
<button type="button" class="btn btn-primary" onclick="storeEquipment()" |
|
id="createBtn">新增</button> |
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button> |
|
</div> |
|
|
|
</form> |
|
</div> |
|
</div> |
|
</div> |
|
</div>
|
|
|