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.
187 lines
8.6 KiB
187 lines
8.6 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 ($('#equipment_serialnumber_create').val() == '' || $('#equipment_location_create').val() == '' || $( |
|
'#equipment_precinct_create').val() == '' || $('#equipment_station_create').val() == '') { |
|
Swal.fire({ |
|
icon: 'error', |
|
title: 'Error', |
|
text: '請填寫必填欄位' |
|
}); |
|
return |
|
} |
|
// Perform Ajax request |
|
$.ajax({ |
|
url: `/api/overspeed/device`, // 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: 'Success', |
|
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: 'Error', |
|
text: response.message |
|
}); |
|
} |
|
}, |
|
error: function(xhr, status, error) { |
|
// Show error alert with the error details |
|
Swal.fire({ |
|
icon: 'error', |
|
title: 'Error', |
|
text: 'An error occurred. Please try again.' |
|
}); |
|
} |
|
}); |
|
} |
|
// 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">設備管理</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="equipment_serialnumber_create">設備編號<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="equipment_serialnumber_create" |
|
name="serialnumber"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_location_create">設置地點<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="equipment_location_create" name="location"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_precinct_create">分局<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="equipment_precinct_create" name="precinct" required> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_station_create">使用單位<span class="text-danger">*</span></label> |
|
<input type="text" class="form-control" id="equipment_station_create" name="station" required> |
|
</div> |
|
<div> |
|
<hr> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_brand_create">廠牌</label> |
|
<input type="text" class="form-control" id="equipment_brand_create" name="brand"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_model_create">型號</label> |
|
<input type="text" class="form-control" id="equipment_model_create" name="model"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="assetownership_id">財產所屬單位</label> |
|
<select class="form-control" name="assetownership_id" id="assetownership_id_create"> |
|
<option value="">請選擇</option> |
|
<option value="create">...新增</option> |
|
<option value="" disabled>────────────</option> |
|
@if (isset($assetownership)) |
|
@foreach ($assetownership as $item) |
|
<option value="{{ $item->id }}">{{ $item->name }}</option> |
|
@endforeach |
|
@endif |
|
</select> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="custodyunit_id">保管單位</label> |
|
<select class="form-control" name="custodyunit_id" id="custodyunit_id_create"> |
|
<option value="">請選擇</option> |
|
<option value="create">...新增</option> |
|
<option value="" disabled>────────────</option> |
|
@if (isset($custodyunit)) |
|
@foreach ($custodyunit as $item) |
|
<option value="{{ $item->id }}">{{ $item->name }}</option> |
|
@endforeach |
|
@endif |
|
</select> |
|
</div> |
|
|
|
|
|
<div class="form-group col-3"> |
|
<label for="buydate_create">購入日期</label> |
|
<input type="date" class="form-control" id="buydate_create" name="buydate"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="activatedate_create">啟用日期</label> |
|
<input type="date" class="form-control" id="activatedate_create" name="activatedate"> |
|
</div> |
|
<div class="form-group col-3"> |
|
<label for="equipment_locationid_create">地點編號</label> |
|
<input type="text" class="form-control" id="equipment_locationid_create" name="locationid"> |
|
</div> |
|
|
|
<div class="form-group col-12"> |
|
<label for="equipment_remark_create">備註</label> |
|
<textarea class="form-control" name="comment" id="equipment_remark_create" cols="30" rows="3"></textarea> |
|
</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>
|
|
|